From a65c3b497fd0ca28f35cb7e63f5a1ce95baff8ad Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Sun, 6 Apr 2025 01:44:18 +0200 Subject: [PATCH] gccrs: 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(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 94585dc1344..aa6ad5066aa 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 -- 2.47.2