public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] add lang item "phantom_data"
@ 2022-11-16 11:49 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-11-16 11:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d8d81d818ded0c450fdbd6c70456ed67fe469c16

commit d8d81d818ded0c450fdbd6c70456ed67fe469c16
Author: Raiki Tamura <tamaron1203@gmail.com>
Date:   Wed Nov 9 18:49:12 2022 +0900

    add lang item "phantom_data"

Diff:
---
 gcc/rust/util/rust-lang-item.h                     |  9 +++++++++
 gcc/testsuite/rust/compile/torture/phantom_data.rs | 11 +++++++++++
 2 files changed, 20 insertions(+)

diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index 111a8673c44..a9751218930 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -73,6 +73,9 @@ public:
     MUT_PTR,
     CONST_SLICE_PTR,
 
+    // https://github.com/rust-lang/rust/blob/master/library/core/src/marker.rs
+    PHANTOM_DATA,
+
     // functions
     FN_ONCE,
     FN_ONCE_OUTPUT,
@@ -222,6 +225,10 @@ public:
       {
 	return ItemType::CONST_SLICE_PTR;
       }
+    else if (item.compare ("phantom_data") == 0)
+      {
+  return ItemType::PHANTOM_DATA;
+      }
     else if (item.compare ("fn_once") == 0)
       {
 	return ItemType::FN_ONCE;
@@ -308,6 +315,8 @@ public:
 	return "mut_ptr";
       case CONST_SLICE_PTR:
 	return "const_slice_ptr";
+      case PHANTOM_DATA:
+  return "phantom_data";
       case FN_ONCE:
 	return "fn_once";
       case FN_ONCE_OUTPUT:
diff --git a/gcc/testsuite/rust/compile/torture/phantom_data.rs b/gcc/testsuite/rust/compile/torture/phantom_data.rs
new file mode 100644
index 00000000000..89e76aeb5eb
--- /dev/null
+++ b/gcc/testsuite/rust/compile/torture/phantom_data.rs
@@ -0,0 +1,11 @@
+// { dg-options "-w" }
+#[lang = "phantom_data"]
+struct PhantomData<T>;
+
+trait Hash {
+    fn hash<H>(&self, state: &mut H);
+}
+
+impl<T> Hash for PhantomData<T> {
+    fn hash<H>(&self, state: &mut H) {}
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-16 11:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 11:49 [gcc/devel/rust/master] add lang item "phantom_data" Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).