aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-08 08:10:05 +0100
committereldritch horrors <pennae@lix.systems>2024-03-09 07:00:13 -0700
commitb221a14f0a477db06f8ab705bd08404e431ec135 (patch)
tree33cab3bfa39ca17a070e1afca13e531052021eee /src/libexpr
parent3d9c7fc1e72e3471ae35c96ec418e8ac0913b099 (diff)
Merge pull request #9925 from 9999years/fmt-cleanup
Cleanup `fmt.hh` (cherry picked from commit 47a1dbb4b8e7913cbb9b4d604728b912e76e4ca0) Change-Id: Id076a45cb39652f437fe3f8bda10c310a9894777
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval-error.cc10
-rw-r--r--src/libexpr/eval-error.hh2
-rw-r--r--src/libexpr/eval.cc8
-rw-r--r--src/libexpr/eval.hh2
-rw-r--r--src/libexpr/flake/flake.cc4
-rw-r--r--src/libexpr/lexer.l6
-rw-r--r--src/libexpr/parser-state.hh8
-rw-r--r--src/libexpr/parser.y8
-rw-r--r--src/libexpr/primops.cc10
-rw-r--r--src/libexpr/primops/fetchClosure.cc22
-rw-r--r--src/libexpr/print.cc2
-rw-r--r--src/libexpr/print.hh2
-rw-r--r--src/libexpr/value-to-json.cc4
-rw-r--r--src/libexpr/value/context.hh4
14 files changed, 46 insertions, 46 deletions
diff --git a/src/libexpr/eval-error.cc b/src/libexpr/eval-error.cc
index 250c59a19..f4cdeec5c 100644
--- a/src/libexpr/eval-error.cc
+++ b/src/libexpr/eval-error.cc
@@ -28,7 +28,7 @@ template<class T>
EvalErrorBuilder<T> & EvalErrorBuilder<T>::withTrace(PosIdx pos, const std::string_view text)
{
error.err.traces.push_front(
- Trace{.pos = error.state.positions[pos], .hint = hintfmt(std::string(text)), .frame = false});
+ Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text)), .frame = false});
return *this;
}
@@ -36,7 +36,7 @@ template<class T>
EvalErrorBuilder<T> & EvalErrorBuilder<T>::withFrameTrace(PosIdx pos, const std::string_view text)
{
error.err.traces.push_front(
- Trace{.pos = error.state.positions[pos], .hint = hintformat(std::string(text)), .frame = true});
+ Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text)), .frame = true});
return *this;
}
@@ -57,13 +57,13 @@ EvalErrorBuilder<T> & EvalErrorBuilder<T>::withFrame(const Env & env, const Expr
.pos = error.state.positions[expr.getPos()],
.expr = expr,
.env = env,
- .hint = hintformat("Fake frame for debugging purposes"),
+ .hint = HintFmt("Fake frame for debugging purposes"),
.isError = true});
return *this;
}
template<class T>
-EvalErrorBuilder<T> & EvalErrorBuilder<T>::addTrace(PosIdx pos, hintformat hint, bool frame)
+EvalErrorBuilder<T> & EvalErrorBuilder<T>::addTrace(PosIdx pos, HintFmt hint, bool frame)
{
error.addTrace(error.state.positions[pos], hint, frame);
return *this;
@@ -75,7 +75,7 @@ EvalErrorBuilder<T> &
EvalErrorBuilder<T>::addTrace(PosIdx pos, std::string_view formatString, const Args &... formatArgs)
{
- addTrace(error.state.positions[pos], hintfmt(std::string(formatString), formatArgs...));
+ addTrace(error.state.positions[pos], HintFmt(std::string(formatString), formatArgs...));
return *this;
}
diff --git a/src/libexpr/eval-error.hh b/src/libexpr/eval-error.hh
index e9076f28b..2bb607280 100644
--- a/src/libexpr/eval-error.hh
+++ b/src/libexpr/eval-error.hh
@@ -90,7 +90,7 @@ public:
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & withFrame(const Env & e, const Expr & ex);
- [[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & addTrace(PosIdx pos, hintformat hint, bool frame = false);
+ [[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & addTrace(PosIdx pos, HintFmt hint, bool frame = false);
template<typename... Args>
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> &
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index fac67950b..ba9fe9c65 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -809,7 +809,7 @@ void EvalState::addErrorTrace(Error & e, const char * s, const std::string & s2)
void EvalState::addErrorTrace(Error & e, const PosIdx pos, const char * s, const std::string & s2, bool frame) const
{
- e.addTrace(positions[pos], hintfmt(s, s2), frame);
+ e.addTrace(positions[pos], HintFmt(s, s2), frame);
}
template<typename... Args>
@@ -825,7 +825,7 @@ static std::unique_ptr<DebugTraceStacker> makeDebugTraceStacker(
.pos = std::move(pos),
.expr = expr,
.env = env,
- .hint = hintfmt(formatArgs...),
+ .hint = HintFmt(formatArgs...),
.isError = false
});
}
@@ -2782,7 +2782,7 @@ std::optional<std::string> EvalState::resolveSearchPathPath(const SearchPath::Pa
res = { store->toRealPath(storePath) };
} catch (FileTransferError & e) {
logWarning({
- .msg = hintfmt("Nix search path entry '%1%' cannot be downloaded, ignoring", value)
+ .msg = HintFmt("Nix search path entry '%1%' cannot be downloaded, ignoring", value)
});
res = std::nullopt;
}
@@ -2802,7 +2802,7 @@ std::optional<std::string> EvalState::resolveSearchPathPath(const SearchPath::Pa
res = { path };
else {
logWarning({
- .msg = hintfmt("Nix search path entry '%1%' does not exist, ignoring", value)
+ .msg = HintFmt("Nix search path entry '%1%' does not exist, ignoring", value)
});
res = std::nullopt;
}
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 325ae792c..135e5fecb 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -147,7 +147,7 @@ struct DebugTrace {
std::shared_ptr<Pos> pos;
const Expr & expr;
const Env & env;
- hintformat hint;
+ HintFmt hint;
bool isError;
};
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index e45526a6c..305d84a68 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -148,7 +148,7 @@ static FlakeInput parseFlakeInput(EvalState & state,
} catch (Error & e) {
e.addTrace(
state.positions[attr.pos],
- hintfmt("while evaluating flake attribute '%s'", state.symbols[attr.name]));
+ HintFmt("while evaluating flake attribute '%s'", state.symbols[attr.name]));
throw;
}
}
@@ -157,7 +157,7 @@ static FlakeInput parseFlakeInput(EvalState & state,
try {
input.ref = FlakeRef::fromAttrs(attrs);
} catch (Error & e) {
- e.addTrace(state.positions[pos], hintfmt("while evaluating flake input"));
+ e.addTrace(state.positions[pos], HintFmt("while evaluating flake input"));
throw;
}
else {
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index fb06c3d69..adb9d9757 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -153,7 +153,7 @@ or { return OR_KW; }
yylval->n = boost::lexical_cast<int64_t>(yytext);
} catch (const boost::bad_lexical_cast &) {
throw ParseError(ErrorInfo{
- .msg = hintfmt("invalid integer '%1%'", yytext),
+ .msg = HintFmt("invalid integer '%1%'", yytext),
.pos = state->positions[CUR_POS],
});
}
@@ -163,7 +163,7 @@ or { return OR_KW; }
yylval->nf = strtod(yytext, 0);
if (errno != 0)
throw ParseError(ErrorInfo{
- .msg = hintfmt("invalid float '%1%'", yytext),
+ .msg = HintFmt("invalid float '%1%'", yytext),
.pos = state->positions[CUR_POS],
});
return FLOAT;
@@ -292,7 +292,7 @@ or { return OR_KW; }
<INPATH_SLASH>{ANY} |
<INPATH_SLASH><<EOF>> {
throw ParseError(ErrorInfo{
- .msg = hintfmt("path has a trailing slash"),
+ .msg = HintFmt("path has a trailing slash"),
.pos = state->positions[CUR_POS],
});
}
diff --git a/src/libexpr/parser-state.hh b/src/libexpr/parser-state.hh
index 2fc072ca4..acadb676d 100644
--- a/src/libexpr/parser-state.hh
+++ b/src/libexpr/parser-state.hh
@@ -63,7 +63,7 @@ struct ParserState
inline void ParserState::dupAttr(const AttrPath & attrPath, const PosIdx pos, const PosIdx prevPos)
{
throw ParseError({
- .msg = hintfmt("attribute '%1%' already defined at %2%",
+ .msg = HintFmt("attribute '%1%' already defined at %2%",
showAttrPath(symbols, attrPath), positions[prevPos]),
.pos = positions[pos]
});
@@ -72,7 +72,7 @@ inline void ParserState::dupAttr(const AttrPath & attrPath, const PosIdx pos, co
inline void ParserState::dupAttr(Symbol attr, const PosIdx pos, const PosIdx prevPos)
{
throw ParseError({
- .msg = hintfmt("attribute '%1%' already defined at %2%", symbols[attr], positions[prevPos]),
+ .msg = HintFmt("attribute '%1%' already defined at %2%", symbols[attr], positions[prevPos]),
.pos = positions[pos]
});
}
@@ -153,13 +153,13 @@ inline Formals * ParserState::validateFormals(Formals * formals, PosIdx pos, Sym
}
if (duplicate)
throw ParseError({
- .msg = hintfmt("duplicate formal function argument '%1%'", symbols[duplicate->first]),
+ .msg = HintFmt("duplicate formal function argument '%1%'", symbols[duplicate->first]),
.pos = positions[duplicate->second]
});
if (arg && formals->has(arg))
throw ParseError({
- .msg = hintfmt("duplicate formal function argument '%1%'", symbols[arg]),
+ .msg = HintFmt("duplicate formal function argument '%1%'", symbols[arg]),
.pos = positions[pos]
});
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index fc83ee2dd..447e4d61a 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -63,7 +63,7 @@ using namespace nix;
void yyerror(YYLTYPE * loc, yyscan_t scanner, ParserState * state, const char * error)
{
throw ParseError({
- .msg = hintfmt(error),
+ .msg = HintFmt(error),
.pos = state->positions[state->at(*loc)]
});
}
@@ -152,7 +152,7 @@ expr_function
| LET binds IN expr_function
{ if (!$2->dynamicAttrs.empty())
throw ParseError({
- .msg = hintfmt("dynamic attributes not allowed in let"),
+ .msg = HintFmt("dynamic attributes not allowed in let"),
.pos = state->positions[CUR_POS]
});
$$ = new ExprLet($2, $4);
@@ -242,7 +242,7 @@ expr_simple
static bool noURLLiterals = experimentalFeatureSettings.isEnabled(Xp::NoUrlLiterals);
if (noURLLiterals)
throw ParseError({
- .msg = hintfmt("URL literals are disabled"),
+ .msg = HintFmt("URL literals are disabled"),
.pos = state->positions[CUR_POS]
});
$$ = new ExprString(std::string($1));
@@ -338,7 +338,7 @@ attrs
delete str;
} else
throw ParseError({
- .msg = hintfmt("dynamic attributes not allowed in inherit"),
+ .msg = HintFmt("dynamic attributes not allowed in inherit"),
.pos = state->positions[state->at(@2)]
});
}
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 8e06d55a1..86db527f6 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -748,7 +748,7 @@ static RegisterPrimOp primop_break({
if (state.debugRepl && !state.debugTraces.empty()) {
auto error = Error(ErrorInfo {
.level = lvlInfo,
- .msg = hintfmt("breakpoint reached"),
+ .msg = HintFmt("breakpoint reached"),
.pos = state.positions[pos],
});
@@ -759,7 +759,7 @@ static RegisterPrimOp primop_break({
// If the user elects to quit the repl, throw an exception.
throw Error(ErrorInfo{
.level = lvlInfo,
- .msg = hintfmt("quit the debugger"),
+ .msg = HintFmt("quit the debugger"),
.pos = nullptr,
});
}
@@ -814,7 +814,7 @@ static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value * *
auto message = state.coerceToString(pos, *args[0], context,
"while evaluating the error message passed to builtins.addErrorContext",
false, false).toOwned();
- e.addTrace(nullptr, hintfmt(message), true);
+ e.addTrace(nullptr, HintFmt(message), true);
throw;
}
}
@@ -1065,7 +1065,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
* often results from the composition of several functions
* (derivationStrict, derivation, mkDerivation, mkPythonModule, etc.)
*/
- e.addTrace(nullptr, hintfmt(
+ e.addTrace(nullptr, HintFmt(
"while evaluating derivation '%s'\n"
" whose name attribute is located at %s",
drvName, pos), true);
@@ -1226,7 +1226,7 @@ drvName, Bindings * attrs, Value & v)
} catch (Error & e) {
e.addTrace(state.positions[i->pos],
- hintfmt("while evaluating attribute '%1%' of derivation '%2%'", key, drvName),
+ HintFmt("while evaluating attribute '%1%' of derivation '%2%'", key, drvName),
true);
throw;
}
diff --git a/src/libexpr/primops/fetchClosure.cc b/src/libexpr/primops/fetchClosure.cc
index ca2a3df9c..3804db6eb 100644
--- a/src/libexpr/primops/fetchClosure.cc
+++ b/src/libexpr/primops/fetchClosure.cc
@@ -22,7 +22,7 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
auto rewrittenPath = makeContentAddressed(fromStore, *state.store, fromPath);
if (toPathMaybe && *toPathMaybe != rewrittenPath)
throw Error({
- .msg = hintfmt("rewriting '%s' to content-addressed form yielded '%s', while '%s' was expected",
+ .msg = HintFmt("rewriting '%s' to content-addressed form yielded '%s', while '%s' was expected",
state.store->printStorePath(fromPath),
state.store->printStorePath(rewrittenPath),
state.store->printStorePath(*toPathMaybe)),
@@ -30,7 +30,7 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
});
if (!toPathMaybe)
throw Error({
- .msg = hintfmt(
+ .msg = HintFmt(
"rewriting '%s' to content-addressed form yielded '%s'\n"
"Use this value for the 'toPath' attribute passed to 'fetchClosure'",
state.store->printStorePath(fromPath),
@@ -49,7 +49,7 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
// We don't perform the rewriting when outPath already exists, as an optimisation.
// However, we can quickly detect a mistake if the toPath is input addressed.
throw Error({
- .msg = hintfmt(
+ .msg = HintFmt(
"The 'toPath' value '%s' is input-addressed, so it can't possibly be the result of rewriting to a content-addressed path.\n\n"
"Set 'toPath' to an empty string to make Nix report the correct content-addressed path.",
state.store->printStorePath(toPath)),
@@ -72,7 +72,7 @@ static void runFetchClosureWithContentAddressedPath(EvalState & state, const Pos
if (!info->isContentAddressed(*state.store)) {
throw Error({
- .msg = hintfmt(
+ .msg = HintFmt(
"The 'fromPath' value '%s' is input-addressed, but 'inputAddressed' is set to 'false' (default).\n\n"
"If you do intend to fetch an input-addressed store path, add\n\n"
" inputAddressed = true;\n\n"
@@ -98,7 +98,7 @@ static void runFetchClosureWithInputAddressedPath(EvalState & state, const PosId
if (info->isContentAddressed(*state.store)) {
throw Error({
- .msg = hintfmt(
+ .msg = HintFmt(
"The store object referred to by 'fromPath' at '%s' is not input-addressed, but 'inputAddressed' is set to 'true'.\n\n"
"Remove the 'inputAddressed' attribute (it defaults to 'false') to expect 'fromPath' to be content-addressed",
state.store->printStorePath(fromPath)),
@@ -152,14 +152,14 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value * * arg
else
throw Error({
- .msg = hintfmt("attribute '%s' isn't supported in call to 'fetchClosure'", attrName),
+ .msg = HintFmt("attribute '%s' isn't supported in call to 'fetchClosure'", attrName),
.pos = state.positions[pos]
});
}
if (!fromPath)
throw Error({
- .msg = hintfmt("attribute '%s' is missing in call to 'fetchClosure'", "fromPath"),
+ .msg = HintFmt("attribute '%s' is missing in call to 'fetchClosure'", "fromPath"),
.pos = state.positions[pos]
});
@@ -168,7 +168,7 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value * * arg
if (inputAddressed) {
if (toPath)
throw Error({
- .msg = hintfmt("attribute '%s' is set to true, but '%s' is also set. Please remove one of them",
+ .msg = HintFmt("attribute '%s' is set to true, but '%s' is also set. Please remove one of them",
"inputAddressed",
"toPath"),
.pos = state.positions[pos]
@@ -177,7 +177,7 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value * * arg
if (!fromStoreUrl)
throw Error({
- .msg = hintfmt("attribute '%s' is missing in call to 'fetchClosure'", "fromStore"),
+ .msg = HintFmt("attribute '%s' is missing in call to 'fetchClosure'", "fromStore"),
.pos = state.positions[pos]
});
@@ -187,13 +187,13 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value * * arg
parsedURL.scheme != "https" &&
!(getEnv("_NIX_IN_TEST").has_value() && parsedURL.scheme == "file"))
throw Error({
- .msg = hintfmt("'fetchClosure' only supports http:// and https:// stores"),
+ .msg = HintFmt("'fetchClosure' only supports http:// and https:// stores"),
.pos = state.positions[pos]
});
if (!parsedURL.query.empty())
throw Error({
- .msg = hintfmt("'fetchClosure' does not support URL query parameters (in '%s')", *fromStoreUrl),
+ .msg = HintFmt("'fetchClosure' does not support URL query parameters (in '%s')", *fromStoreUrl),
.pos = state.positions[pos]
});
diff --git a/src/libexpr/print.cc b/src/libexpr/print.cc
index 86eadfb17..b792f657d 100644
--- a/src/libexpr/print.cc
+++ b/src/libexpr/print.cc
@@ -510,7 +510,7 @@ std::ostream & operator<<(std::ostream & output, const ValuePrinter & printer)
}
template<>
-hintformat & hintformat::operator%(const ValuePrinter & value)
+HintFmt & HintFmt::operator%(const ValuePrinter & value)
{
fmt % value;
return *this;
diff --git a/src/libexpr/print.hh b/src/libexpr/print.hh
index a542bc7b1..7ddda81b8 100644
--- a/src/libexpr/print.hh
+++ b/src/libexpr/print.hh
@@ -86,6 +86,6 @@ std::ostream & operator<<(std::ostream & output, const ValuePrinter & printer);
* magenta.
*/
template<>
-hintformat & hintformat::operator%(const ValuePrinter & value);
+HintFmt & HintFmt::operator%(const ValuePrinter & value);
}
diff --git a/src/libexpr/value-to-json.cc b/src/libexpr/value-to-json.cc
index ab479520b..787a46426 100644
--- a/src/libexpr/value-to-json.cc
+++ b/src/libexpr/value-to-json.cc
@@ -64,7 +64,7 @@ json printValueAsJSON(EvalState & state, bool strict,
out[j] = printValueAsJSON(state, strict, *a.value, a.pos, context, copyToStore);
} catch (Error & e) {
e.addTrace(state.positions[a.pos],
- hintfmt("while evaluating attribute '%1%'", j));
+ HintFmt("while evaluating attribute '%1%'", j));
throw;
}
}
@@ -81,7 +81,7 @@ json printValueAsJSON(EvalState & state, bool strict,
out.push_back(printValueAsJSON(state, strict, *elem, pos, context, copyToStore));
} catch (Error & e) {
e.addTrace(state.positions[pos],
- hintfmt("while evaluating list element at index %1%", i));
+ HintFmt("while evaluating list element at index %1%", i));
throw;
}
i++;
diff --git a/src/libexpr/value/context.hh b/src/libexpr/value/context.hh
index 9f1d59317..998b70e36 100644
--- a/src/libexpr/value/context.hh
+++ b/src/libexpr/value/context.hh
@@ -20,8 +20,8 @@ public:
: Error("")
{
raw = raw_;
- auto hf = hintfmt(args...);
- err.msg = hintfmt("Bad String Context element: %1%: %2%", normaltxt(hf.str()), raw);
+ auto hf = HintFmt(args...);
+ err.msg = HintFmt("Bad String Context element: %1%: %2%", Uncolored(hf.str()), raw);
}
};