]> git.proxmox.com Git - rustc.git/blame - src/test/debuginfo/unsized.rs
New upstream version 1.60.0+dfsg1
[rustc.git] / src / test / debuginfo / unsized.rs
CommitLineData
32a655c1
SL
1// compile-flags:-g
2
3// === GDB TESTS ===================================================================================
4
5// gdb-command:run
6
5099ac24
FG
7// gdb-command:print a
8// gdbg-check:$1 = {data_ptr = [...], length = 4}
9// gdbr-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4}
32a655c1 10
5099ac24
FG
11// gdb-command:print b
12// gdbg-check:$2 = {data_ptr = [...], length = 4}
13// gdbr-check:$2 = &unsized::Foo<unsized::Foo<[u8]>> {data_ptr: [...], length: 4}
32a655c1 14
5099ac24
FG
15// gdb-command:print c
16// gdbg-check:$3 = {pointer = [...], vtable = [...]}
17// gdbr-check:$3 = &unsized::Foo<dyn core::fmt::Debug> {pointer: [...], vtable: [...]}
32a655c1 18
5099ac24
FG
19// gdb-command:print tuple_slice
20// gdbg-check:$4 = {data_ptr = [...], length = 2}
21// gdbr-check:$4 = &(i32, i32, [i32]) {data_ptr: [...], length: 2}
22
23// gdb-command:print tuple_dyn
24// gdbg-check:$5 = {pointer = [...], vtable = [...]}
25// gdbr-check:$5 = &(i32, i32, dyn core::fmt::Debug) {pointer: [...], vtable: [...]}
26
27// === CDB TESTS ===================================================================================
28
29// cdb-command: g
30// cdb-command:dx a
31// cdb-check:a [Type: ref$<unsized::Foo<slice$<u8> > >]
32// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<slice$<u8> > *]
33// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
34
35// cdb-command:dx b
36// cdb-check:b [Type: ref$<unsized::Foo<unsized::Foo<slice$<u8> > > >]
37// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<unsized::Foo<slice$<u8> > > *]
38// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
39
40// cdb-command:dx c
41// cdb-check:c [Type: ref$<unsized::Foo<dyn$<core::fmt::Debug> > >]
42// cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *]
43// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
44
45// cdb-command:dx tuple_slice
46// cdb-check:tuple_slice [Type: ref$<tuple$<i32,i32,slice$<i32> > >]
47// cdb-check: [+0x000] data_ptr : 0x[...] [Type: tuple$<i32,i32,slice$<i32> > *]
48// cdb-check: [...] length : 0x2 [Type: unsigned [...]int[...]
49
50// cdb-command:dx tuple_dyn
51// cdb-check:tuple_dyn [Type: ref$<tuple$<i32,i32,dyn$<core::fmt::Debug> > >]
52// cdb-check: [+0x000] pointer : 0x[...] [Type: tuple$<i32,i32,dyn$<core::fmt::Debug> > *]
53// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
54
55#![feature(unsized_tuple_coercion)]
32a655c1
SL
56#![feature(omit_gdb_pretty_printer_section)]
57#![omit_gdb_pretty_printer_section]
58
59struct Foo<T: ?Sized> {
5099ac24 60 value: T,
32a655c1
SL
61}
62
63fn main() {
5099ac24
FG
64 let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } };
65
66 // We expect `a`, `b`, and `c` to all be fat pointers.
67 // `a` and `b` should be slice-like and thus have a `data_ptr` and `length` field.
68 // `c` should be trait-object-like and thus have a `pointer` and `vtable` field.
32a655c1
SL
69 let a: &Foo<[u8]> = &foo.value;
70 let b: &Foo<Foo<[u8]>> = &foo;
5099ac24
FG
71 let c: &Foo<dyn std::fmt::Debug> = &Foo { value: 7i32 };
72
73 // Also check unsized tuples
74 let tuple_slice: &(i32, i32, [i32]) = &(0, 1, [2, 3]);
75 let tuple_dyn: &(i32, i32, dyn std::fmt::Debug) = &(0, 1, &3u64);
32a655c1
SL
76
77 zzz(); // #break
78}
79
5099ac24
FG
80fn zzz() {
81 ()
82}