diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index b42dc0e7b..966c9887f 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -882,13 +882,9 @@ std::string EvalState::mkOutputStringRaw( return ctx.store->printStorePath(staticOutputPath); } - -void EvalState::mkOutputString( - Value & value, - const SingleDerivedPath::Built & b, - const StorePath & staticOutputPath) +Value EvalState::mkOutputString(const SingleDerivedPath::Built & b, const StorePath & staticOutputPath) { - value = {NewValueAs::string, mkOutputStringRaw(staticOutputPath), NixStringContext{b}}; + return {NewValueAs::string, mkOutputStringRaw(staticOutputPath), NixStringContext{b}}; } diff --git a/lix/libexpr/eval.hh b/lix/libexpr/eval.hh index e5bca7824..656154d2f 100644 --- a/lix/libexpr/eval.hh +++ b/lix/libexpr/eval.hh @@ -809,18 +809,13 @@ public: * single `NixStringContextElem::Built` element of the drv path and * output name. * - * @param value Value we are settings - * * @param b the drv whose output we are making a string for, and the * output * * @param staticOutputPath Output path for that string. * Will be printed to form string. */ - void mkOutputString( - Value & value, - const SingleDerivedPath::Built & b, - const StorePath & staticOutputPath); + Value mkOutputString(const SingleDerivedPath::Built & b, const StorePath & staticOutputPath); /** * Create a string representing a `SingleDerivedPath`. diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index 9cbba8621..398aa9955 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -158,13 +158,13 @@ static void mkOutputString( const StorePath & drvPath, const std::pair & o) { - state.mkOutputString( - attrs.alloc(o.first), - SingleDerivedPath::Built { + attrs.alloc(o.first) = state.mkOutputString( + SingleDerivedPath::Built{ .drvPath = makeConstantStorePath(drvPath), .output = o.first, }, - o.second.path(*state.ctx.store, Derivation::nameFromPath(drvPath), o.first)); + o.second.path(*state.ctx.store, Derivation::nameFromPath(drvPath), o.first) + ); } /* Load and evaluate an expression from path specified by the diff --git a/tests/unit/libexpr/derived-path.cc b/tests/unit/libexpr/derived-path.cc index 1dd61719c..bb9611dbd 100644 --- a/tests/unit/libexpr/derived-path.cc +++ b/tests/unit/libexpr/derived-path.cc @@ -41,8 +41,7 @@ RC_GTEST_FIXTURE_PROP( prop_derived_path_built_out_path_round_trip, (const SingleDerivedPath::Built & b, const StorePath & outPath)) { - Value v; - state.mkOutputString(v, b, outPath); + Value v = state.mkOutputString(b, outPath); auto [d, _] = state.coerceToSingleDerivedPathUnchecked(noPos, v, ""); RC_ASSERT(SingleDerivedPath { b } == d); }