]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add hash function for Identifiers
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Sat, 5 Apr 2025 23:44:18 +0000 (01:44 +0200)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Thu, 24 Apr 2025 16:53:44 +0000 (16:53 +0000)
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 5f302bc80d3119f6a92cfdcdded9a7f81ea32ae9..9581dd57b739009be9d372e9c5a62defac1a9fb0 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