From 4de049a3f9709ab8b0b192c40e83b910b80d6de3 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 23 Apr 2025 11:42:26 +0200 Subject: [PATCH] Deprecate `ObjectSpace._id2ref` [Feature #15408] Matz decided to deprecate it for Ruby 2.6 or 2.7 but that never actually happened. Given the object_id table is a contention point for Ractors it seems sensible to finally deprecate this API so we can generate and store object ids more efficiently in the future. --- gc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gc.c b/gc.c index 953b2ed70d..0ca08d53e0 100644 --- a/gc.c +++ b/gc.c @@ -1965,6 +1965,8 @@ rb_gc_obj_free_vm_weak_references(VALUE obj) * * On multi-ractor mode, if the object is not shareable, it raises * RangeError. + * + * This method is deprecated and should no longer be used. */ static VALUE @@ -2012,6 +2014,7 @@ id2ref(VALUE objid) static VALUE os_id2ref(VALUE os, VALUE objid) { + rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "ObjectSpace._id2ref is deprecated"); return id2ref(objid); }