Skip to content

Commit 27136db

Browse files
Merge #1633
1633: Implement PhantomData r=CohenArthur a=tamaroning Fixes #1127 Added `phantom_data` lang item Co-authored-by: Raiki Tamura <[email protected]>
2 parents 716ae8d + f726b12 commit 27136db

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

gcc/rust/util/rust-lang-item.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class RustLangItem
7373
MUT_PTR,
7474
CONST_SLICE_PTR,
7575

76+
// https://github.com/rust-lang/rust/blob/master/library/core/src/marker.rs
77+
PHANTOM_DATA,
78+
7679
// functions
7780
FN_ONCE,
7881
FN_ONCE_OUTPUT,
@@ -222,6 +225,10 @@ class RustLangItem
222225
{
223226
return ItemType::CONST_SLICE_PTR;
224227
}
228+
else if (item.compare ("phantom_data") == 0)
229+
{
230+
return ItemType::PHANTOM_DATA;
231+
}
225232
else if (item.compare ("fn_once") == 0)
226233
{
227234
return ItemType::FN_ONCE;
@@ -308,6 +315,8 @@ class RustLangItem
308315
return "mut_ptr";
309316
case CONST_SLICE_PTR:
310317
return "const_slice_ptr";
318+
case PHANTOM_DATA:
319+
return "phantom_data";
311320
case FN_ONCE:
312321
return "fn_once";
313322
case FN_ONCE_OUTPUT:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// { dg-options "-w" }
2+
#[lang = "phantom_data"]
3+
struct PhantomData<T>;
4+
5+
trait Hash {
6+
fn hash<H>(&self, state: &mut H);
7+
}
8+
9+
impl<T> Hash for PhantomData<T> {
10+
fn hash<H>(&self, state: &mut H) {}
11+
}

0 commit comments

Comments
 (0)