2016-12-22 11:13:33 +00:00
|
|
|
// compile-flags:-g
|
|
|
|
|
|
|
|
// === GDB TESTS ===================================================================================
|
|
|
|
|
|
|
|
// gdb-command:run
|
|
|
|
|
2022-01-13 17:13:54 +00:00
|
|
|
// gdb-command:print a
|
2022-01-25 11:14:17 +00:00
|
|
|
// gdbg-check:$1 = {data_ptr = [...], length = 4}
|
2022-01-13 17:13:54 +00:00
|
|
|
// gdbr-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4}
|
2016-12-22 11:13:33 +00:00
|
|
|
|
2022-01-13 17:13:54 +00:00
|
|
|
// gdb-command:print b
|
2022-01-25 11:14:17 +00:00
|
|
|
// gdbg-check:$2 = {data_ptr = [...], length = 4}
|
2022-01-13 17:13:54 +00:00
|
|
|
// gdbr-check:$2 = &unsized::Foo<unsized::Foo<[u8]>> {data_ptr: [...], length: 4}
|
|
|
|
|
|
|
|
// gdb-command:print c
|
2022-01-25 11:14:17 +00:00
|
|
|
// gdbg-check:$3 = {pointer = [...], vtable = [...]}
|
2022-01-13 17:13:54 +00:00
|
|
|
// gdbr-check:$3 = &unsized::Foo<dyn core::fmt::Debug> {pointer: [...], vtable: [...]}
|
|
|
|
|
2022-03-24 09:59:28 +00:00
|
|
|
// gdb-command:print _box
|
|
|
|
// gdbg-check:$4 = {pointer = [...], vtable = [...]}
|
|
|
|
// gdbr-check:$4 = alloc::boxed::Box<unsized::Foo<dyn core::fmt::Debug>, alloc::alloc::Global> {pointer: [...], vtable: [...]}
|
|
|
|
|
2022-02-16 10:18:01 +00:00
|
|
|
// gdb-command:print tuple_slice
|
2022-03-24 09:59:28 +00:00
|
|
|
// gdbg-check:$5 = {data_ptr = [...], length = 2}
|
|
|
|
// gdbr-check:$5 = &(i32, i32, [i32]) {data_ptr: [...], length: 2}
|
2022-02-16 10:18:01 +00:00
|
|
|
|
|
|
|
// gdb-command:print tuple_dyn
|
2022-03-24 09:59:28 +00:00
|
|
|
// gdbg-check:$6 = {pointer = [...], vtable = [...]}
|
|
|
|
// gdbr-check:$6 = &(i32, i32, dyn core::fmt::Debug) {pointer: [...], vtable: [...]}
|
2022-02-16 10:18:01 +00:00
|
|
|
|
2022-01-13 17:13:54 +00:00
|
|
|
// === CDB TESTS ===================================================================================
|
|
|
|
|
|
|
|
// cdb-command: g
|
|
|
|
// cdb-command:dx a
|
[debuginfo] Make debuginfo type names for slices and str consistent.
Before this PR, the compiler would emit the debuginfo name `slice$<T>`
for all kinds of slices, regardless of whether they are behind a
reference or not and regardless of the kind of reference. As a
consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>`
would end up with the same type name `Foo<slice$<T> >` in debuginfo,
making it impossible to disambiguate between them by name. Similarly,
`&str` would get the name `str` in debuginfo, so the debuginfo name for
`Foo<str>` and `Foo<&str>` would be the same. In contrast,
`*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >`
and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose
information about the type.
This PR removes all special handling for slices and `str`. The types
`&[bool]`, `&mut [bool]`, and `&str` thus get the names
`ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and
`ref$<str$>` respectively -- as one would expect.
2022-10-25 10:28:03 +00:00
|
|
|
// cdb-check:a [Type: ref$<unsized::Foo<slice2$<u8> > >]
|
|
|
|
// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<slice2$<u8> > *]
|
2022-01-25 11:14:17 +00:00
|
|
|
// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
|
2022-01-13 17:13:54 +00:00
|
|
|
|
|
|
|
// cdb-command:dx b
|
[debuginfo] Make debuginfo type names for slices and str consistent.
Before this PR, the compiler would emit the debuginfo name `slice$<T>`
for all kinds of slices, regardless of whether they are behind a
reference or not and regardless of the kind of reference. As a
consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>`
would end up with the same type name `Foo<slice$<T> >` in debuginfo,
making it impossible to disambiguate between them by name. Similarly,
`&str` would get the name `str` in debuginfo, so the debuginfo name for
`Foo<str>` and `Foo<&str>` would be the same. In contrast,
`*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >`
and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose
information about the type.
This PR removes all special handling for slices and `str`. The types
`&[bool]`, `&mut [bool]`, and `&str` thus get the names
`ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and
`ref$<str$>` respectively -- as one would expect.
2022-10-25 10:28:03 +00:00
|
|
|
// cdb-check:b [Type: ref$<unsized::Foo<unsized::Foo<slice2$<u8> > > >]
|
|
|
|
// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<unsized::Foo<slice2$<u8> > > *]
|
2022-01-25 11:14:17 +00:00
|
|
|
// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
|
2022-01-13 17:13:54 +00:00
|
|
|
|
|
|
|
// cdb-command:dx c
|
|
|
|
// cdb-check:c [Type: ref$<unsized::Foo<dyn$<core::fmt::Debug> > >]
|
|
|
|
// cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *]
|
2022-01-25 11:14:17 +00:00
|
|
|
// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
|
2016-12-22 11:13:33 +00:00
|
|
|
|
2022-03-24 09:59:28 +00:00
|
|
|
// cdb-command:dx _box
|
|
|
|
// cdb-check:
|
|
|
|
// cdb-check:_box [Type: alloc::boxed::Box<unsized::Foo<dyn$<core::fmt::Debug> >,alloc::alloc::Global>]
|
|
|
|
// cdb-check:[+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *]
|
|
|
|
// cdb-check:[...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
|
|
|
|
|
2022-02-16 10:18:01 +00:00
|
|
|
// cdb-command:dx tuple_slice
|
[debuginfo] Make debuginfo type names for slices and str consistent.
Before this PR, the compiler would emit the debuginfo name `slice$<T>`
for all kinds of slices, regardless of whether they are behind a
reference or not and regardless of the kind of reference. As a
consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>`
would end up with the same type name `Foo<slice$<T> >` in debuginfo,
making it impossible to disambiguate between them by name. Similarly,
`&str` would get the name `str` in debuginfo, so the debuginfo name for
`Foo<str>` and `Foo<&str>` would be the same. In contrast,
`*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >`
and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose
information about the type.
This PR removes all special handling for slices and `str`. The types
`&[bool]`, `&mut [bool]`, and `&str` thus get the names
`ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and
`ref$<str$>` respectively -- as one would expect.
2022-10-25 10:28:03 +00:00
|
|
|
// cdb-check:tuple_slice [Type: ref$<tuple$<i32,i32,slice2$<i32> > >]
|
|
|
|
// cdb-check: [+0x000] data_ptr : 0x[...] [Type: tuple$<i32,i32,slice2$<i32> > *]
|
2022-02-16 10:18:01 +00:00
|
|
|
// cdb-check: [...] length : 0x2 [Type: unsigned [...]int[...]
|
|
|
|
|
|
|
|
// cdb-command:dx tuple_dyn
|
|
|
|
// cdb-check:tuple_dyn [Type: ref$<tuple$<i32,i32,dyn$<core::fmt::Debug> > >]
|
|
|
|
// cdb-check: [+0x000] pointer : 0x[...] [Type: tuple$<i32,i32,dyn$<core::fmt::Debug> > *]
|
|
|
|
// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
|
|
|
|
|
|
|
|
#![feature(unsized_tuple_coercion)]
|
2016-12-22 11:13:33 +00:00
|
|
|
#![feature(omit_gdb_pretty_printer_section)]
|
|
|
|
#![omit_gdb_pretty_printer_section]
|
|
|
|
|
|
|
|
struct Foo<T: ?Sized> {
|
2022-01-25 11:14:17 +00:00
|
|
|
value: T,
|
2016-12-22 11:13:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2022-01-25 11:14:17 +00:00
|
|
|
let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } };
|
2022-01-13 17:13:54 +00:00
|
|
|
|
|
|
|
// We expect `a`, `b`, and `c` to all be fat pointers.
|
|
|
|
// `a` and `b` should be slice-like and thus have a `data_ptr` and `length` field.
|
|
|
|
// `c` should be trait-object-like and thus have a `pointer` and `vtable` field.
|
2016-12-22 11:13:33 +00:00
|
|
|
let a: &Foo<[u8]> = &foo.value;
|
|
|
|
let b: &Foo<Foo<[u8]>> = &foo;
|
2022-01-13 17:13:54 +00:00
|
|
|
let c: &Foo<dyn std::fmt::Debug> = &Foo { value: 7i32 };
|
2022-03-24 09:59:28 +00:00
|
|
|
let _box: Box<Foo<dyn std::fmt::Debug>> = Box::new(Foo { value: 8i32 });
|
2016-12-22 11:13:33 +00:00
|
|
|
|
2022-02-16 10:18:01 +00:00
|
|
|
// Also check unsized tuples
|
|
|
|
let tuple_slice: &(i32, i32, [i32]) = &(0, 1, [2, 3]);
|
|
|
|
let tuple_dyn: &(i32, i32, dyn std::fmt::Debug) = &(0, 1, &3u64);
|
|
|
|
|
2016-12-22 11:13:33 +00:00
|
|
|
zzz(); // #break
|
|
|
|
}
|
|
|
|
|
2022-01-25 11:14:17 +00:00
|
|
|
fn zzz() {
|
|
|
|
()
|
|
|
|
}
|