1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 14:21:48 +02:00

SingleDerivedPath should be const in recursive data structures

This commit is contained in:
John Ericson 2025-03-03 10:31:23 -05:00
parent 89b495520d
commit 8fdb50761d
4 changed files with 11 additions and 11 deletions

View file

@ -333,9 +333,9 @@ Goal::Co DerivationGoal::gaveUpOnSubstitution()
/* The inputs must be built before we can build this goal. */ /* The inputs must be built before we can build this goal. */
inputDrvOutputs.clear(); inputDrvOutputs.clear();
if (useDerivation) { if (useDerivation) {
std::function<void(ref<SingleDerivedPath>, const DerivedPathMap<StringSet>::ChildNode &)> addWaiteeDerivedPath; std::function<void(ref<const SingleDerivedPath>, const DerivedPathMap<StringSet>::ChildNode &)> addWaiteeDerivedPath;
addWaiteeDerivedPath = [&](ref<SingleDerivedPath> inputDrv, const DerivedPathMap<StringSet>::ChildNode & inputNode) { addWaiteeDerivedPath = [&](ref<const SingleDerivedPath> inputDrv, const DerivedPathMap<StringSet>::ChildNode & inputNode) {
if (!inputNode.value.empty()) if (!inputNode.value.empty())
addWaitee(worker.makeGoal( addWaitee(worker.makeGoal(
DerivedPath::Built { DerivedPath::Built {

View file

@ -170,7 +170,7 @@ void drvRequireExperiment(
} }
SingleDerivedPath::Built SingleDerivedPath::Built::parse( SingleDerivedPath::Built SingleDerivedPath::Built::parse(
const StoreDirConfig & store, ref<SingleDerivedPath> drv, const StoreDirConfig & store, ref<const SingleDerivedPath> drv,
OutputNameView output, OutputNameView output,
const ExperimentalFeatureSettings & xpSettings) const ExperimentalFeatureSettings & xpSettings)
{ {
@ -182,7 +182,7 @@ SingleDerivedPath::Built SingleDerivedPath::Built::parse(
} }
DerivedPath::Built DerivedPath::Built::parse( DerivedPath::Built DerivedPath::Built::parse(
const StoreDirConfig & store, ref<SingleDerivedPath> drv, const StoreDirConfig & store, ref<const SingleDerivedPath> drv,
OutputNameView outputsS, OutputNameView outputsS,
const ExperimentalFeatureSettings & xpSettings) const ExperimentalFeatureSettings & xpSettings)
{ {
@ -201,7 +201,7 @@ static SingleDerivedPath parseWithSingle(
return n == s.npos return n == s.npos
? (SingleDerivedPath) SingleDerivedPath::Opaque::parse(store, s) ? (SingleDerivedPath) SingleDerivedPath::Opaque::parse(store, s)
: (SingleDerivedPath) SingleDerivedPath::Built::parse(store, : (SingleDerivedPath) SingleDerivedPath::Built::parse(store,
make_ref<SingleDerivedPath>(parseWithSingle( make_ref<const SingleDerivedPath>(parseWithSingle(
store, store,
s.substr(0, n), s.substr(0, n),
separator, separator,
@ -234,7 +234,7 @@ static DerivedPath parseWith(
return n == s.npos return n == s.npos
? (DerivedPath) DerivedPath::Opaque::parse(store, s) ? (DerivedPath) DerivedPath::Opaque::parse(store, s)
: (DerivedPath) DerivedPath::Built::parse(store, : (DerivedPath) DerivedPath::Built::parse(store,
make_ref<SingleDerivedPath>(parseWithSingle( make_ref<const SingleDerivedPath>(parseWithSingle(
store, store,
s.substr(0, n), s.substr(0, n),
separator, separator,

View file

@ -45,7 +45,7 @@ struct SingleDerivedPath;
* path of the given output name. * path of the given output name.
*/ */
struct SingleDerivedPathBuilt { struct SingleDerivedPathBuilt {
ref<SingleDerivedPath> drvPath; ref<const SingleDerivedPath> drvPath;
OutputName output; OutputName output;
/** /**
@ -74,7 +74,7 @@ struct SingleDerivedPathBuilt {
* @param xpSettings Stop-gap to avoid globals during unit tests. * @param xpSettings Stop-gap to avoid globals during unit tests.
*/ */
static SingleDerivedPathBuilt parse( static SingleDerivedPathBuilt parse(
const StoreDirConfig & store, ref<SingleDerivedPath> drvPath, const StoreDirConfig & store, ref<const SingleDerivedPath> drvPath,
OutputNameView outputs, OutputNameView outputs,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings); const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
nlohmann::json toJSON(Store & store) const; nlohmann::json toJSON(Store & store) const;
@ -172,7 +172,7 @@ static inline ref<SingleDerivedPath> makeConstantStorePathRef(StorePath drvPath)
* output name. * output name.
*/ */
struct DerivedPathBuilt { struct DerivedPathBuilt {
ref<SingleDerivedPath> drvPath; ref<const SingleDerivedPath> drvPath;
OutputsSpec outputs; OutputsSpec outputs;
/** /**
@ -201,7 +201,7 @@ struct DerivedPathBuilt {
* @param xpSettings Stop-gap to avoid globals during unit tests. * @param xpSettings Stop-gap to avoid globals during unit tests.
*/ */
static DerivedPathBuilt parse( static DerivedPathBuilt parse(
const StoreDirConfig & store, ref<SingleDerivedPath>, const StoreDirConfig & store, ref<const SingleDerivedPath>,
std::string_view, std::string_view,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings); const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
nlohmann::json toJSON(Store & store) const; nlohmann::json toJSON(Store & store) const;

View file

@ -35,7 +35,7 @@ struct CmdLog : InstallableCommand
// For compat with CLI today, TODO revisit // For compat with CLI today, TODO revisit
auto oneUp = std::visit(overloaded { auto oneUp = std::visit(overloaded {
[&](const DerivedPath::Opaque & bo) { [&](const DerivedPath::Opaque & bo) {
return make_ref<SingleDerivedPath>(bo); return make_ref<const SingleDerivedPath>(bo);
}, },
[&](const DerivedPath::Built & bfd) { [&](const DerivedPath::Built & bfd) {
return bfd.drvPath; return bfd.drvPath;