From: Pierre-Emmanuel Patry Date: Sat, 5 Apr 2025 23:44:18 +0000 (+0200) Subject: gccrs: Add hash function for Identifiers X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a65c3b497fd0ca28f35cb7e63f5a1ce95baff8ad;p=thirdparty%2Fgcc.git gccrs: Add hash function for Identifiers gcc/rust/ChangeLog: * ast/rust-ast.h: Add hash function. Signed-off-by: Pierre-Emmanuel Patry --- 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