Skip to content

Commit 6e291fb

Browse files
committed
DynMemory log statements now use Debug instead of type_name::<T>()
1 parent 641664b commit 6e291fb

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

godot-core/src/obj/bounds.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl Sealed for MemRefCounted {}
208208
impl Memory for MemRefCounted {}
209209
impl DynMemory for MemRefCounted {
210210
fn maybe_init_ref<T: GodotClass>(obj: &mut RawGd<T>) {
211-
out!(" MemRefc::init <{}>", std::any::type_name::<T>());
211+
out!(" MemRefc::init: {obj:?}");
212212
if obj.is_null() {
213213
return;
214214
}
@@ -226,7 +226,7 @@ impl DynMemory for MemRefCounted {
226226
}
227227

228228
fn maybe_inc_ref<T: GodotClass>(obj: &mut RawGd<T>) {
229-
out!(" MemRefc::inc <{}>", std::any::type_name::<T>());
229+
out!(" MemRefc::inc: {obj:?}");
230230
if obj.is_null() {
231231
return;
232232
}
@@ -237,7 +237,7 @@ impl DynMemory for MemRefCounted {
237237
}
238238

239239
unsafe fn maybe_dec_ref<T: GodotClass>(obj: &mut RawGd<T>) -> bool {
240-
out!(" MemRefc::dec <{}>", std::any::type_name::<T>());
240+
out!(" MemRefc::dec: {obj:?}");
241241
if obj.is_null() {
242242
return false;
243243
}
@@ -278,7 +278,7 @@ impl MemDynamic {
278278
impl Sealed for MemDynamic {}
279279
impl DynMemory for MemDynamic {
280280
fn maybe_init_ref<T: GodotClass>(obj: &mut RawGd<T>) {
281-
out!(" MemDyn::init <{}>", std::any::type_name::<T>());
281+
out!(" MemDyn::init: {obj:?}");
282282
if Self::inherits_refcounted(obj) {
283283
// Will call `RefCounted::init_ref()` which checks for liveness.
284284
out!(" MemDyn -> MemRefc");
@@ -289,15 +289,15 @@ impl DynMemory for MemDynamic {
289289
}
290290

291291
fn maybe_inc_ref<T: GodotClass>(obj: &mut RawGd<T>) {
292-
out!(" MemDyn::inc <{}>", std::any::type_name::<T>());
292+
out!(" MemDyn::inc: {obj:?}");
293293
if Self::inherits_refcounted(obj) {
294294
// Will call `RefCounted::reference()` which checks for liveness.
295295
MemRefCounted::maybe_inc_ref(obj)
296296
}
297297
}
298298

299299
unsafe fn maybe_dec_ref<T: GodotClass>(obj: &mut RawGd<T>) -> bool {
300-
out!(" MemDyn::dec <{}>", std::any::type_name::<T>());
300+
out!(" MemDyn::dec: {obj:?}");
301301
if obj
302302
.instance_id_unchecked()
303303
.is_some_and(|id| id.is_ref_counted())

godot-core/src/obj/raw_gd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ impl<T: GodotClass> Drop for RawGd<T> {
653653
fn drop(&mut self) {
654654
// No-op for manually managed objects
655655

656-
out!("RawGd::drop <{}>", std::any::type_name::<T>());
656+
out!("RawGd::drop: {self:?}");
657657

658658
// SAFETY: This `Gd` won't be dropped again after this.
659659
// If destruction is triggered by Godot, Storage already knows about it, no need to notify it
@@ -668,7 +668,7 @@ impl<T: GodotClass> Drop for RawGd<T> {
668668

669669
impl<T: GodotClass> Clone for RawGd<T> {
670670
fn clone(&self) -> Self {
671-
out!("RawGd::clone");
671+
out!("RawGd::clone: {self:?} (before clone)");
672672

673673
if self.is_null() {
674674
Self::null()

godot-core/src/storage/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ fn bug_inaccessible<T>(err: Box<dyn std::error::Error>) -> ! {
5353
)
5454
}
5555

56-
fn log_construct<T>() {
56+
fn log_construct<T: GodotClass>(base: &Base<T::Base>) {
5757
out!(
58-
" Storage::construct <{ty}>",
58+
" Storage::construct: {base:?} (T={ty})",
5959
ty = type_name::<T>()
6060
);
6161
}
6262

6363
fn log_inc_ref<T: StorageRefCounted>(storage: &T) {
6464
out!(
65-
" Storage::on_inc_ref (rc={rc}) <{ty}> -- {base:?}",
65+
" Storage::on_inc_ref (rc={rc}): {base:?} (T={ty})",
6666
rc = T::godot_ref_count(storage),
6767
base = storage.base(),
6868
ty = type_name::<T>(),
@@ -71,7 +71,7 @@ fn log_inc_ref<T: StorageRefCounted>(storage: &T) {
7171

7272
fn log_dec_ref<T: StorageRefCounted>(storage: &T) {
7373
out!(
74-
" | Storage::on_dec_ref (rc={rc}) <{ty}> -- {base:?}",
74+
" | Storage::on_dec_ref (rc={rc}): {base:?} (T={ty})",
7575
rc = T::godot_ref_count(storage),
7676
base = storage.base(),
7777
ty = type_name::<T>(),
@@ -80,7 +80,7 @@ fn log_dec_ref<T: StorageRefCounted>(storage: &T) {
8080

8181
fn log_drop<T: StorageRefCounted>(storage: &T) {
8282
out!(
83-
" Storage::drop (rc={rc}) <{base:?}>",
83+
" Storage::drop (rc={rc}): {base:?}",
8484
rc = storage.godot_ref_count(),
8585
base = storage.base(),
8686
);
@@ -92,6 +92,7 @@ fn log_drop<T: StorageRefCounted>(storage: &T) {
9292
#[cfg(debug_assertions)]
9393
use borrow_info::DebugBorrowTracker;
9494

95+
use crate::obj::{Base, GodotClass};
9596
#[cfg(not(debug_assertions))]
9697
use borrow_info_noop::DebugBorrowTracker;
9798

godot-core/src/storage/multi_threaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ unsafe impl<T: GodotClass> Storage for InstanceStorage<T> {
4343
user_instance: Self::Instance,
4444
base: Base<<Self::Instance as GodotClass>::Base>,
4545
) -> Self {
46-
super::log_construct::<T>();
46+
super::log_construct::<T>(&base);
4747

4848
Self {
4949
user_instance: GdCell::new(user_instance),

godot-core/src/storage/single_threaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ unsafe impl<T: GodotClass> Storage for InstanceStorage<T> {
4343
user_instance: Self::Instance,
4444
base: Base<<Self::Instance as GodotClass>::Base>,
4545
) -> Self {
46-
super::log_construct::<T>();
46+
super::log_construct::<T>(&base);
4747

4848
Self {
4949
user_instance: GdCell::new(user_instance),

0 commit comments

Comments
 (0)