about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
committerVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
commit838f86b0fd880b26539664140f04e5d16669dad8 (patch)
treec8fee2f0c136fbe5bb0735604e2f04d5b02698ba /third_party/nix/src/libexpr/eval.cc
parentf30b2e610d9e612504a9f6460e0cc83413b80aeb (diff)
style(3p/nix): Remove 'using std::*' from types.hh r/840
It is considered bad form to use things from includes in headers, as
these directives propagate to everywhere else and can make it
confusing.

types.hh (which is includes almost literally everywhere) had some of
these directives, which this commit removes.
Diffstat (limited to 'third_party/nix/src/libexpr/eval.cc')
-rw-r--r--third_party/nix/src/libexpr/eval.cc41
1 files changed, 22 insertions, 19 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 60d3cd012d..d93f39bba4 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -136,7 +136,7 @@ const Value* getPrimOp(const Value& v) {
   return primOp;
 }
 
-string showType(const Value& v) {
+std::string showType(const Value& v) {
   switch (v.type) {
     case tInt:
       return "an integer";
@@ -163,10 +163,10 @@ string showType(const Value& v) {
     case tBlackhole:
       return "a black hole";
     case tPrimOp:
-      return fmt("the built-in function '%s'", string(v.primOp->name));
+      return fmt("the built-in function '%s'", std::string(v.primOp->name));
     case tPrimOpApp:
       return fmt("the partially applied built-in function '%s'",
-                 string(getPrimOp(v)->primOp->name));
+                 std::string(getPrimOp(v)->primOp->name));
     case tExternal:
       return v.external->showType();
     case tFloat:
@@ -456,7 +456,8 @@ Value* EvalState::addConstant(const std::string& name, Value& v) {
   *v2 = v;
   staticBaseEnv.vars[symbols.Create(name)] = baseEnvDispl;
   baseEnv.values[baseEnvDispl++] = v2;
-  std::string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name;
+  std::string name2 =
+      std::string(name, 0, 2) == "__" ? std::string(name, 2) : name;
   baseEnv.values[0]->attrs->push_back(Attr(symbols.Create(name2), v2));
   return v2;
 }
@@ -469,7 +470,8 @@ Value* EvalState::addPrimOp(const std::string& name, size_t arity,
     return addConstant(name, v);
   }
   Value* v = allocValue();
-  std::string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name;
+  std::string name2 =
+      std::string(name, 0, 2) == "__" ? std::string(name, 2) : name;
   Symbol sym = symbols.Create(name2);
   v->type = tPrimOp;
   v->primOp = new PrimOp(primOp, arity, sym);
@@ -1423,7 +1425,7 @@ void EvalState::forceFunction(Value& v, const Pos& pos) {
   }
 }
 
-string EvalState::forceString(Value& v, const Pos& pos) {
+std::string EvalState::forceString(Value& v, const Pos& pos) {
   forceValue(v, pos);
   if (v.type != tString) {
     if (pos) {
@@ -1433,7 +1435,7 @@ string EvalState::forceString(Value& v, const Pos& pos) {
       throwTypeError("value is %1% while a string was expected", v);
     }
   }
-  return string(v.string.s);
+  return std::string(v.string.s);
 }
 
 void copyContext(const Value& v, PathSet& context) {
@@ -1444,13 +1446,13 @@ void copyContext(const Value& v, PathSet& context) {
   }
 }
 
-string EvalState::forceString(Value& v, PathSet& context, const Pos& pos) {
+std::string EvalState::forceString(Value& v, PathSet& context, const Pos& pos) {
   std::string s = forceString(v, pos);
   copyContext(v, context);
   return s;
 }
 
-string EvalState::forceStringNoCtx(Value& v, const Pos& pos) {
+std::string EvalState::forceStringNoCtx(Value& v, const Pos& pos) {
   std::string s = forceString(v, pos);
   if (v.string.context != nullptr) {
     if (pos) {
@@ -1483,10 +1485,10 @@ bool EvalState::isDerivation(Value& v) {
   return strcmp(i->second.value->string.s, "derivation") == 0;
 }
 
-std::optional<string> EvalState::tryAttrsToString(const Pos& pos, Value& v,
-                                                  PathSet& context,
-                                                  bool coerceMore,
-                                                  bool copyToStore) {
+std::optional<std::string> EvalState::tryAttrsToString(const Pos& pos, Value& v,
+                                                       PathSet& context,
+                                                       bool coerceMore,
+                                                       bool copyToStore) {
   auto i = v.attrs->find(sToString);
   if (i != v.attrs->end()) {
     Value v1;
@@ -1497,8 +1499,9 @@ std::optional<string> EvalState::tryAttrsToString(const Pos& pos, Value& v,
   return {};
 }
 
-string EvalState::coerceToString(const Pos& pos, Value& v, PathSet& context,
-                                 bool coerceMore, bool copyToStore) {
+std::string EvalState::coerceToString(const Pos& pos, Value& v,
+                                      PathSet& context, bool coerceMore,
+                                      bool copyToStore) {
   forceValue(v);
 
   std::string s;
@@ -1569,7 +1572,7 @@ string EvalState::coerceToString(const Pos& pos, Value& v, PathSet& context,
   throwTypeError("cannot coerce %1% to a string, at %2%", v, pos);
 }
 
-string EvalState::copyPathToStore(PathSet& context, const Path& path) {
+std::string EvalState::copyPathToStore(PathSet& context, const Path& path) {
   if (nix::isDerivation(path)) {
     throwEvalError("file names are not allowed to end in '%1%'", drvExtension);
   }
@@ -1931,9 +1934,9 @@ size_t valueSize(Value& v) {
   return doValue(v);
 }
 
-string ExternalValueBase::coerceToString(const Pos& pos, PathSet& context,
-                                         bool copyMore,
-                                         bool copyToStore) const {
+std::string ExternalValueBase::coerceToString(const Pos& pos, PathSet& context,
+                                              bool copyMore,
+                                              bool copyToStore) const {
   throw TypeError(format("cannot coerce %1% to a string, at %2%") % showType() %
                   pos);
 }