Skip to content

Commit 14fdf8a

Browse files
committed
Add test for Unique<T>, weak ref counts and ref counts for Weak<T>
1 parent d1852e1 commit 14fdf8a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/etc/natvis/liballoc.natvis

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@
6464
<Expand>
6565
<ExpandedItem>ptr.pointer->value</ExpandedItem>
6666
<Item Name="[Reference count]">ptr.pointer->strong</Item>
67+
<Item Name="[Weak reference count]">ptr.pointer->weak</Item>
6768
</Expand>
6869
</Type>
6970
<Type Name="alloc::rc::Weak&lt;*&gt;">
7071
<DisplayString>{ptr.pointer->value}</DisplayString>
7172
<Expand>
7273
<ExpandedItem>ptr.pointer->value</ExpandedItem>
74+
<Item Name="[Reference count]">ptr.pointer->strong</Item>
75+
<Item Name="[Weak reference count]">ptr.pointer->weak</Item>
7376
</Expand>
7477
</Type>
7578

@@ -78,12 +81,15 @@
7881
<Expand>
7982
<ExpandedItem>ptr.pointer->data</ExpandedItem>
8083
<Item Name="[Reference count]">ptr.pointer->strong</Item>
84+
<Item Name="[Weak reference count]">ptr.pointer->weak</Item>
8185
</Expand>
8286
</Type>
8387
<Type Name="alloc::sync::Weak&lt;*&gt;">
8488
<DisplayString>{ptr.pointer->data}</DisplayString>
8589
<Expand>
8690
<ExpandedItem>ptr.pointer->data</ExpandedItem>
91+
<Item Name="[Reference count]">ptr.pointer->strong</Item>
92+
<Item Name="[Weak reference count]">ptr.pointer->weak</Item>
8793
</Expand>
8894
</Type>
8995
<Type Name="alloc::borrow::Cow&lt;*&gt;">

src/test/debuginfo/marker-types.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@
2121
// cdb-check: [capacity] : 0x4 [Type: unsigned __int64]
2222
// cdb-check: [chars] : "this"
2323

24+
// cdb-command: dx unique
25+
// cdb-check:unique : Unique(0x[...]: (0x2a, 4321)) [Type: core::ptr::unique::Unique<tuple$<u64,i32> >]
26+
// cdb-check: [<Raw View>] [Type: core::ptr::unique::Unique<tuple$<u64,i32> >]
27+
// cdb-check: [0] : 0x2a [Type: unsigned __int64]
28+
// cdb-check: [1] : 4321 [Type: int]
29+
30+
#![feature(ptr_internals)]
31+
2432
use std::mem::ManuallyDrop;
2533
use std::pin::Pin;
26-
use std::ptr::NonNull;
34+
use std::ptr::{NonNull, Unique};
2735

2836
fn main() {
2937
let nonnull: NonNull<_> = (&12u32).into();
@@ -33,6 +41,8 @@ fn main() {
3341
let mut s = "this".to_string();
3442
let pin = Pin::new(&mut s);
3543

44+
let unique: Unique<_> = (&mut (42u64, 4321i32)).into();
45+
3646
zzz(); // #break
3747
}
3848

src/test/debuginfo/rc_arc.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,37 @@
3131
// cdb-check:r,d : 42 [Type: alloc::rc::Rc<i32>]
3232
// cdb-check: [<Raw View>] [Type: alloc::rc::Rc<i32>]
3333
// cdb-check: [Reference count] : 2 [Type: core::cell::Cell<usize>]
34+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
3435

3536
// cdb-command:dx r1,d
3637
// cdb-check:r1,d : 42 [Type: alloc::rc::Rc<i32>]
3738
// cdb-check: [<Raw View>] [Type: alloc::rc::Rc<i32>]
3839
// cdb-check: [Reference count] : 2 [Type: core::cell::Cell<usize>]
40+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
3941

4042
// cdb-command:dx w1,d
4143
// cdb-check:w1,d : 42 [Type: alloc::rc::Weak<i32>]
4244
// cdb-check: [<Raw View>] [Type: alloc::rc::Weak<i32>]
45+
// cdb-check: [Reference count] : 2 [Type: core::cell::Cell<usize>]
46+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
4347

4448
// cdb-command:dx a,d
4549
// cdb-check:a,d : 42 [Type: alloc::sync::Arc<i32>]
4650
// cdb-check: [<Raw View>] [Type: alloc::sync::Arc<i32>]
4751
// cdb-check: [Reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
52+
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
4853

4954
// cdb-command:dx a1,d
5055
// cdb-check:a1,d : 42 [Type: alloc::sync::Arc<i32>]
5156
// cdb-check: [<Raw View>] [Type: alloc::sync::Arc<i32>]
5257
// cdb-check: [Reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
58+
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
5359

5460
// cdb-command:dx w2,d
5561
// cdb-check:w2,d : 42 [Type: alloc::sync::Weak<i32>]
5662
// cdb-check: [<Raw View>] [Type: alloc::sync::Weak<i32>]
63+
// cdb-check: [Reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
64+
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
5765

5866
use std::rc::Rc;
5967
use std::sync::Arc;

0 commit comments

Comments
 (0)