aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2022-03-04 19:47:32 +0100
committerpennae <github@quasiparticle.net>2022-04-21 21:25:18 +0200
commit38de79fcf7e00187107e638036c010911d1b675b (patch)
tree7d8c5f98e67b15b5d0de7ffc33641765d291acfd /src
parentff0fd91ed23ae9d851bf27c4df3ec77f7028699b (diff)
remove Bindings::need
a future commit will remove the ability to convert the symbol type used in bindings to strings. since we only have two users we can inline the error check.
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/attr-set.hh12
-rw-r--r--src/nix/bundle.cc6
-rw-r--r--src/nix/prefetch.cc10
3 files changed, 10 insertions, 18 deletions
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index cad9743ea..1e6c548c6 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -73,18 +73,6 @@ public:
return nullptr;
}
- Attr & need(const Symbol & name, const Pos & pos = noPos)
- {
- auto a = get(name);
- if (!a)
- throw Error({
- .msg = hintfmt("attribute '%s' missing", name),
- .errPos = pos
- });
-
- return *a;
- }
-
iterator begin() { return &attrs[0]; }
iterator end() { return &attrs[size_]; }
diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc
index 81fb8464a..ee91e8ed0 100644
--- a/src/nix/bundle.cc
+++ b/src/nix/bundle.cc
@@ -110,8 +110,10 @@ struct CmdBundle : InstallableCommand
auto outPathS = store->printStorePath(outPath);
if (!outLink) {
- auto &attr = vRes->attrs->need(evalState->sName);
- outLink = evalState->forceStringNoCtx(*attr.value,*attr.pos);
+ auto * attr = vRes->attrs->get(evalState->sName);
+ if (!attr)
+ throw Error("attribute 'name' missing");
+ outLink = evalState->forceStringNoCtx(*attr->value, *attr->pos);
}
// TODO: will crash if not a localFSStore?
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index f2dd44ba4..ce3288dc1 100644
--- a/src/nix/prefetch.cc
+++ b/src/nix/prefetch.cc
@@ -199,11 +199,13 @@ static int main_nix_prefetch_url(int argc, char * * argv)
state->forceAttrs(v, noPos);
/* Extract the URL. */
- auto & attr = v.attrs->need(state->symbols.create("urls"));
- state->forceList(*attr.value, noPos);
- if (attr.value->listSize() < 1)
+ auto * attr = v.attrs->get(state->symbols.create("urls"));
+ if (!attr)
+ throw Error("attribute 'urls' missing");
+ state->forceList(*attr->value, noPos);
+ if (attr->value->listSize() < 1)
throw Error("'urls' list is empty");
- url = state->forceString(*attr.value->listElems()[0]);
+ url = state->forceString(*attr->value->listElems()[0]);
/* Extract the hash mode. */
auto attr2 = v.attrs->get(state->symbols.create("outputHashMode"));