diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-02-20 17:01:28 +0000 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2025-02-24 08:53:25 +0000 |
commit | 1361615946def3c04cfd44c0f47f1cb1e183d1be (patch) | |
tree | b90b20b8aebef9c9c02e2b2d9314484228858fc3 /gcc/rust/expand/rust-derive.cc | |
parent | 6a02fdab62434fae56fbdceeb40e238d2698d621 (diff) | |
download | gcc-1361615946def3c04cfd44c0f47f1cb1e183d1be.zip gcc-1361615946def3c04cfd44c0f47f1cb1e183d1be.tar.gz gcc-1361615946def3c04cfd44c0f47f1cb1e183d1be.tar.bz2 |
derive(Hash): Add implementation.
gcc/rust/ChangeLog:
* Make-lang.in: Compile it.
* expand/rust-derive.cc (DeriveVisitor::derive): Call it.
* expand/rust-derive-hash.cc: New file.
* expand/rust-derive-hash.h: New file.
gcc/testsuite/ChangeLog:
* rust/compile/derive-hash1.rs: New test.
* rust/compile/nr2/exclude: Add testcase to exclusion list.
Diffstat (limited to 'gcc/rust/expand/rust-derive.cc')
-rw-r--r-- | gcc/rust/expand/rust-derive.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/gcc/rust/expand/rust-derive.cc b/gcc/rust/expand/rust-derive.cc index 8223281..fc8875d 100644 --- a/gcc/rust/expand/rust-derive.cc +++ b/gcc/rust/expand/rust-derive.cc @@ -23,6 +23,7 @@ #include "rust-derive-default.h" #include "rust-derive-eq.h" #include "rust-derive-partial-eq.h" +#include "rust-derive-hash.h" namespace Rust { namespace AST { @@ -35,29 +36,32 @@ std::vector<std::unique_ptr<Item>> DeriveVisitor::derive (Item &item, const Attribute &attr, BuiltinMacro to_derive) { + auto loc = attr.get_locus (); + switch (to_derive) { case BuiltinMacro::Clone: - return vec (DeriveClone (attr.get_locus ()).go (item)); + return vec (DeriveClone (loc).go (item)); case BuiltinMacro::Copy: - return vec (DeriveCopy (attr.get_locus ()).go (item)); + return vec (DeriveCopy (loc).go (item)); case BuiltinMacro::Debug: rust_warning_at ( - attr.get_locus (), 0, + loc, 0, "derive(Debug) is not fully implemented yet and has no effect - only a " "stub implementation will be generated"); - return vec (DeriveDebug (attr.get_locus ()).go (item)); + return vec (DeriveDebug (loc).go (item)); case BuiltinMacro::Default: - return vec (DeriveDefault (attr.get_locus ()).go (item)); + return vec (DeriveDefault (loc).go (item)); case BuiltinMacro::Eq: - return DeriveEq (attr.get_locus ()).go (item); + return DeriveEq (loc).go (item); case BuiltinMacro::PartialEq: - return DerivePartialEq (attr.get_locus ()).go (item); + return DerivePartialEq (loc).go (item); + case BuiltinMacro::Hash: + return vec (DeriveHash (loc).go (item)); case BuiltinMacro::Ord: case BuiltinMacro::PartialOrd: - case BuiltinMacro::Hash: default: - rust_sorry_at (attr.get_locus (), "unimplemented builtin derive macro"); + rust_sorry_at (loc, "unimplemented builtin derive macro"); return {}; }; } |