diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-11-16 09:27:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-16 09:27:49 +0000 |
commit | 27136db8fd7b428870f6c85ae4b328f54c8de4bb (patch) | |
tree | 179e7e14cc35b8a2bf95f8e94a2d3c4ea4b0c177 | |
parent | 716ae8d024dcddd5000f65fa5c7c0dbd9f03c869 (diff) | |
parent | f726b12ca106307d739f1bb483a532a911985441 (diff) | |
download | gcc-27136db8fd7b428870f6c85ae4b328f54c8de4bb.zip gcc-27136db8fd7b428870f6c85ae4b328f54c8de4bb.tar.gz gcc-27136db8fd7b428870f6c85ae4b328f54c8de4bb.tar.bz2 |
Merge #1633
1633: Implement PhantomData r=CohenArthur a=tamaroning
Fixes #1127
Added `phantom_data` lang item
Co-authored-by: Raiki Tamura <tamaron1203@gmail.com>
-rw-r--r-- | gcc/rust/util/rust-lang-item.h | 9 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/phantom_data.rs | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h index 111a867..1aa5794 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 0000000..89e76ae --- /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) {} +} |