about summary refs log tree commit diff
path: root/library/core/src/ptr
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-02-11 23:19:09 +0100
committerGitHub <noreply@github.com>2024-02-11 23:19:09 +0100
commit3d7d709925294ae6d7304242d21a3b5cd3676c15 (patch)
treea8285e27ee414b991d0213851882900fde8aa8bf /library/core/src/ptr
parent4c154a1a48f59f258c822fe81057608c13b9cd1a (diff)
parentaaa6d3bec2d08f425c844f5964782e1d6a1bbc88 (diff)
downloadrust-3d7d709925294ae6d7304242d21a3b5cd3676c15.tar.gz
rust-3d7d709925294ae6d7304242d21a3b5cd3676c15.zip
Rollup merge of #120880 - RalfJung:vtable-fnptr-partialeq, r=cuviper
add note on comparing vtables / function pointers

Fixes https://github.com/rust-lang/rust/issues/99388
Fixes https://github.com/rust-lang/rust/issues/117047
Diffstat (limited to 'library/core/src/ptr')
-rw-r--r--library/core/src/ptr/metadata.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs
index a6a390db043..c7b0fe5694a 100644
--- a/library/core/src/ptr/metadata.rs
+++ b/library/core/src/ptr/metadata.rs
@@ -175,6 +175,11 @@ impl<T: ?Sized> Clone for PtrComponents<T> {
 ///
 /// 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,