add note on comparing vtables / function pointers
This commit is contained in:
parent
0809f78c19
commit
1383657a46
@ -1676,6 +1676,11 @@ mod prim_ref {}
|
||||
/// * [`UnwindSafe`]
|
||||
/// * [`RefUnwindSafe`]
|
||||
///
|
||||
/// Note that while this type implements `PartialEq`, comparing function pointers is unreliable:
|
||||
/// pointers to the same function can compare inequal (because functions are duplicated in multiple
|
||||
/// codegen units), and pointers to *different* functions can compare equal (since identical
|
||||
/// functions can be deduplicated within a codegen unit).
|
||||
///
|
||||
/// [`Hash`]: hash::Hash
|
||||
/// [`Pointer`]: fmt::Pointer
|
||||
/// [`UnwindSafe`]: panic::UnwindSafe
|
||||
|
@ -175,6 +175,11 @@ fn clone(&self) -> Self {
|
||||
///
|
||||
/// It is possible to name this struct with a type parameter that is not a `dyn` trait object
|
||||
/// (for example `DynMetadata<u64>`) but not to obtain a meaningful value of that struct.
|
||||
///
|
||||
/// Note that while this type implements `PartialEq`, comparing vtable pointers is unreliable:
|
||||
/// pointers to vtables of the same type for the same trait can compare inequal (because vtables are
|
||||
/// duplicated in multiple codegen units), and pointers to vtables of *different* types/traits can
|
||||
/// compare equal (since identical vtables can be deduplicated within a codegen unit).
|
||||
#[lang = "dyn_metadata"]
|
||||
pub struct DynMetadata<Dyn: ?Sized> {
|
||||
vtable_ptr: &'static VTable,
|
||||
|
Loading…
Reference in New Issue
Block a user