Add some comments about _marker
fields.
There is some non-obvious information required to understand them.
This commit is contained in:
parent
9a785e0aa5
commit
c2c505737f
@ -49,7 +49,9 @@ pub(super) fn new(handle_counters: &'static HandleCounters) -> Self {
|
||||
#[repr(C)]
|
||||
pub(crate) struct $oty {
|
||||
handle: handle::Handle,
|
||||
// Prevent Send and Sync impls
|
||||
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual
|
||||
// way of doing this, but that requires unstable features.
|
||||
// rust-analyzer uses this code and avoids unstable features.
|
||||
_marker: PhantomData<*mut ()>,
|
||||
}
|
||||
|
||||
@ -133,7 +135,9 @@ fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct $ity {
|
||||
handle: handle::Handle,
|
||||
// Prevent Send and Sync impls
|
||||
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual
|
||||
// way of doing this, but that requires unstable features.
|
||||
// rust-analyzer uses this code and avoids unstable features.
|
||||
_marker: PhantomData<*mut ()>,
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,11 @@
|
||||
pub struct Closure<'a, A, R> {
|
||||
call: unsafe extern "C" fn(*mut Env, A) -> R,
|
||||
env: *mut Env,
|
||||
// Ensure Closure is !Send and !Sync
|
||||
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing
|
||||
// this, but that requires unstable features. rust-analyzer uses this code
|
||||
// and avoids unstable features.
|
||||
//
|
||||
// The `'a` lifetime parameter represents the lifetime of `Env`.
|
||||
_marker: PhantomData<*mut &'a mut ()>,
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,9 @@ pub struct Bridge<'a> {
|
||||
/// If 'true', always invoke the default panic hook
|
||||
force_show_panics: bool,
|
||||
|
||||
// Prevent Send and Sync impls
|
||||
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing
|
||||
// this, but that requires unstable features. rust-analyzer uses this code
|
||||
// and avoids unstable features.
|
||||
_marker: marker::PhantomData<*mut ()>,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user