Skip to content

Commit 03c2aec

Browse files
committed
Use fn() -> T instead of *mut T in PhantomData
Avoids unessicarrily ruining our Sync/Send impl for TypeId and FunctionDefinition
1 parent c8df434 commit 03c2aec

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/funcs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ pub struct FunctionDeclaration<'a, R = (), Args = ()> {
2121
/// Unlike the [PhantomData], this is actually retained at runtime.
2222
pub signature: SignatureDef<'a>,
2323
/// PhantomData: The return type of the function
24-
pub return_type: PhantomData<*mut R>,
24+
pub return_type: PhantomData<fn() -> R>,
2525
/// PhantomData: The argument types of the function
26-
pub arg_types: PhantomData<*mut Args>,
26+
pub arg_types: PhantomData<fn(Args) -> ()>,
2727
}
2828
impl<'a, R, Args> FunctionDeclaration<'a, R, Args> {
2929
/// If the function has a known location at runtime

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![feature(
1414
const_fn, // We rely on const eval :(
1515
const_panic, const_option, // We use Option::unwrap
16+
const_fn_fn_ptr_basics, // We use PhantomData<fn() -> T>
1617
// Used for field_offset macro
1718
const_raw_ptr_deref,
1819
const_raw_ptr_to_usize_cast,

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl<T: StaticReflect> Clone for TypeId<'_, T> {
525525
#[derive(Eq, PartialEq, Hash)]
526526
pub struct TypeId<'a, T: StaticReflect = ()> {
527527
value: &'a TypeInfo<'a>,
528-
marker: PhantomData<*mut T>
528+
marker: PhantomData<fn() -> T>
529529
}
530530
/*
531531
* TODO: Fix to use derive

0 commit comments

Comments
 (0)