Auto merge of #89132 - Cyborus04:rc_allocator_support, r=Amanieu

Add support for allocators in `Rc` & `Arc`

Adds the ability for `std::rc:Rc`, `std::rc::Weak`, `std::sync::Arc`, and `std::sync::Weak` to live in custom allocators
This commit is contained in:
bors 2023-07-17 21:51:46 +00:00
commit da6b55cc5e
5 changed files with 1546 additions and 325 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,10 @@
dyn pointees.
Rc<[T]> and Arc<[T]> are handled separately altogether so we can actually show
the slice values.
the slice values. These visualizers have a second wildcard `foo&lt;slice2$&lt;*&gt;, *&gt;`
which accounts for the allocator parameter. This isn't needed for the other visualizers since
their inner `*` eats the type parameter but since the slice ones match part of the type params
it is necessary for them.
-->
<!-- alloc::rc::Rc<T> -->
<Type Name="alloc::rc::Rc&lt;*&gt;">
@ -84,7 +87,7 @@
</Type>
<!-- alloc::rc::Rc<[T]> -->
<Type Name="alloc::rc::Rc&lt;slice2$&lt;*&gt; &gt;">
<Type Name="alloc::rc::Rc&lt;slice2$&lt;*&gt;,*&gt;">
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
<Expand>
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
@ -114,7 +117,7 @@
</Type>
<!-- alloc::rc::Weak<[T]> -->
<Type Name="alloc::rc::Weak&lt;slice2$&lt;*&gt; &gt;">
<Type Name="alloc::rc::Weak&lt;slice2$&lt;*&gt;,*&gt;">
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
<Expand>
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
@ -143,7 +146,7 @@
</Type>
<!-- alloc::sync::Arc<[T]> -->
<Type Name="alloc::sync::Arc&lt;slice2$&lt;*&gt; &gt;">
<Type Name="alloc::sync::Arc&lt;slice2$&lt;*&gt;,*&gt;">
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
<Expand>
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
@ -172,7 +175,7 @@
</Type>
<!-- alloc::sync::Weak<[T]> -->
<Type Name="alloc::sync::Weak&lt;slice2$&lt;*&gt; &gt;">
<Type Name="alloc::sync::Weak&lt;slice2$&lt;*&gt;,*&gt;">
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
<Expand>
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>

View File

@ -27,37 +27,37 @@
// cdb-command:g
// cdb-command:dx rc,d
// cdb-check:rc,d : 111 [Type: alloc::rc::Rc<i32>]
// cdb-check:rc,d : 111 [Type: alloc::rc::Rc<i32,alloc::alloc::Global>]
// cdb-check: [Reference count] : 11 [Type: core::cell::Cell<usize>]
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
// cdb-command:dx weak_rc,d
// cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak<i32>]
// cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak<i32,alloc::alloc::Global>]
// cdb-check: [Reference count] : 11 [Type: core::cell::Cell<usize>]
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
// cdb-command:dx arc,d
// cdb-check:arc,d : 222 [Type: alloc::sync::Arc<i32>]
// cdb-check:arc,d : 222 [Type: alloc::sync::Arc<i32,alloc::alloc::Global>]
// cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize]
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
// cdb-command:dx weak_arc,d
// cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak<i32>]
// cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak<i32,alloc::alloc::Global>]
// cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize]
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
// cdb-command:dx dyn_rc,d
// cdb-check:dyn_rc,d [Type: alloc::rc::Rc<dyn$<core::fmt::Debug> >]
// cdb-check:dyn_rc,d [Type: alloc::rc::Rc<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
// cdb-check: [Reference count] : 31 [Type: core::cell::Cell<usize>]
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
// cdb-command:dx dyn_rc_weak,d
// cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak<dyn$<core::fmt::Debug> >]
// cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
// cdb-check: [Reference count] : 31 [Type: core::cell::Cell<usize>]
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
// cdb-command:dx slice_rc,d
// cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc<slice2$<u32> >]
// cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc<slice2$<u32>,alloc::alloc::Global>]
// cdb-check: [Length] : 3 [Type: [...]]
// cdb-check: [Reference count] : 41 [Type: core::cell::Cell<usize>]
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
@ -66,7 +66,7 @@
// cdb-check: [2] : 3 [Type: u32]
// cdb-command:dx slice_rc_weak,d
// cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak<slice2$<u32> >]
// cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak<slice2$<u32>,alloc::alloc::Global>]
// cdb-check: [Length] : 3 [Type: [...]]
// cdb-check: [Reference count] : 41 [Type: core::cell::Cell<usize>]
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
@ -75,17 +75,17 @@
// cdb-check: [2] : 3 [Type: u32]
// cdb-command:dx dyn_arc,d
// cdb-check:dyn_arc,d [Type: alloc::sync::Arc<dyn$<core::fmt::Debug> >]
// cdb-check:dyn_arc,d [Type: alloc::sync::Arc<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
// cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize]
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
// cdb-command:dx dyn_arc_weak,d
// cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak<dyn$<core::fmt::Debug> >]
// cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
// cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize]
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
// cdb-command:dx slice_arc,d
// cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc<slice2$<u32> >]
// cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc<slice2$<u32>,alloc::alloc::Global>]
// cdb-check: [Length] : 3 [Type: [...]]
// cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize]
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
@ -94,7 +94,7 @@
// cdb-check: [2] : 6 [Type: u32]
// cdb-command:dx slice_arc_weak,d
// cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak<slice2$<u32> >]
// cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak<slice2$<u32>,alloc::alloc::Global>]
// cdb-check: [Length] : 3 [Type: [...]]
// cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize]
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]

View File

@ -14,7 +14,7 @@
//
// cdb-command:dx t,d
// cdb-check:t,d : [...] [Type: std::thread::Thread *]
// cdb-check:[...] inner [...][Type: core::pin::Pin<alloc::sync::Arc<std::thread::Inner> >]
// cdb-check:[...] inner [...][Type: core::pin::Pin<alloc::sync::Arc<std::thread::Inner,alloc::alloc::Global> >]
use std::thread;