]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/unsized.rs
Auto merge of #93284 - eholk:disable-drop-range-analysis, r=pnkfelix
[rust.git] / src / test / debuginfo / unsized.rs
1 // compile-flags:-g
2
3 // === GDB TESTS ===================================================================================
4
5 // gdb-command:run
6
7 // gdb-command:print a
8 // gdbg-check:$1 = {data_ptr = [...], length = 4}
9 // gdbr-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4}
10
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}
14
15 // gdb-command:print c
16 // gdbg-check:$3 = {pointer = [...], vtable = [...]}
17 // gdbr-check:$3 = &unsized::Foo<dyn core::fmt::Debug> {pointer: [...], vtable: [...]}
18
19 // === CDB TESTS ===================================================================================
20
21 // cdb-command: g
22 // cdb-command:dx a
23 // cdb-check:a                [Type: ref$<unsized::Foo<slice$<u8> > >]
24 // cdb-check:    [+0x000] data_ptr         : 0x[...] [Type: unsized::Foo<slice$<u8> > *]
25 // cdb-check:    [...] length           : 0x4 [Type: unsigned [...]int[...]
26
27 // cdb-command:dx b
28 // cdb-check:b                [Type: ref$<unsized::Foo<unsized::Foo<slice$<u8> > > >]
29 // cdb-check:    [+0x000] data_ptr         : 0x[...] [Type: unsized::Foo<unsized::Foo<slice$<u8> > > *]
30 // cdb-check:    [...] length           : 0x4 [Type: unsigned [...]int[...]
31
32 // cdb-command:dx c
33 // cdb-check:c                [Type: ref$<unsized::Foo<dyn$<core::fmt::Debug> > >]
34 // cdb-check:    [+0x000] pointer          : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *]
35 // cdb-check:    [...] vtable           : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
36
37 #![feature(omit_gdb_pretty_printer_section)]
38 #![omit_gdb_pretty_printer_section]
39
40 struct Foo<T: ?Sized> {
41     value: T,
42 }
43
44 fn main() {
45     let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } };
46
47     // We expect `a`, `b`, and `c` to all be fat pointers.
48     // `a` and `b` should be slice-like and thus have a `data_ptr` and `length` field.
49     // `c` should be trait-object-like and thus have a `pointer` and `vtable` field.
50     let a: &Foo<[u8]> = &foo.value;
51     let b: &Foo<Foo<[u8]>> = &foo;
52     let c: &Foo<dyn std::fmt::Debug> = &Foo { value: 7i32 };
53
54     zzz(); // #break
55 }
56
57 fn zzz() {
58     ()
59 }