]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add hash function for Identifiers
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Sat, 5 Apr 2025 23:44:18 +0000 (01:44 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 28 Apr 2025 14:18:56 +0000 (16:18 +0200)
gcc/rust/ChangeLog:

* ast/rust-ast.h: Add hash function.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast.h

index 94585dc134427744a9f7cc62070bcb01ae9c94f1..aa6ad5066aa136d5cc2d2da0b42710517a703228 100644 (file)
@@ -2102,6 +2102,19 @@ template <> struct less<Rust::Identifier>
     return lhs.as_string () < rhs.as_string ();
   }
 };
+
+template <> struct hash<Rust::Identifier>
+{
+  std::size_t operator() (const Rust::Identifier &k) const
+  {
+    using std::hash;
+    using std::size_t;
+    using std::string;
+
+    return hash<string> () (k.as_string ()) ^ (hash<int> () (k.get_locus ()));
+  }
+};
+
 } // namespace std
 
 #endif