diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 1b263abccbb3672860b8c3e6c9978569c3e58931..8770add64a4069efc6d753f624a33cabda2c5cc2 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -389,17 +389,6 @@ string replaceStrings(const std::string & s,
 std::string rewriteStrings(const std::string & s, const StringMap & rewrites);
 
 
-/* If a set contains 'from', remove it and insert 'to'. */
-template<typename T>
-void replaceInSet(std::set<T> & set, const T & from, const T & to)
-{
-    auto i = set.find(from);
-    if (i == set.end()) return;
-    set.erase(i);
-    set.insert(to);
-}
-
-
 /* Convert the exit status of a child as returned by wait() into an
    error string. */
 string statusToString(int status);
diff --git a/tests/unit-tests/test-util.cc b/tests/unit-tests/test-util.cc
index 62ca8f11ccf5fd59bd5e8184e27a9377f818e299..e0738614e794bdea57702b2a0cc7cecabc26189a 100644
--- a/tests/unit-tests/test-util.cc
+++ b/tests/unit-tests/test-util.cc
@@ -364,10 +364,6 @@ namespace nix {
         ASSERT_EQ(statusOk(1), false);
     }
 
-    /* ----------------------------------------------------------------------------
-     * replaceInSet : XXX: this function isn't called anywhere!
-     * --------------------------------------------------------------------------*/
-
 
     /* ----------------------------------------------------------------------------
      * rewriteStrings