From 22c008cc523fcc12fe03a244a61d327e06df35bf Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Sun, 6 Apr 2025 01:44:18 +0200 Subject: Add hash function for Identifiers gcc/rust/ChangeLog: * ast/rust-ast.h: Add hash function. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-ast.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 5f302bc..9581dd5 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -2102,6 +2102,19 @@ template <> struct less return lhs.as_string () < rhs.as_string (); } }; + +template <> struct hash +{ + std::size_t operator() (const Rust::Identifier &k) const + { + using std::hash; + using std::size_t; + using std::string; + + return hash () (k.as_string ()) ^ (hash () (k.get_locus ())); + } +}; + } // namespace std #endif -- cgit v1.1