Skip to content

Commit 4916e2b

Browse files
committedAug 15, 2022
Auto merge of #98393 - michaelwoerister:new-cpp-like-enum-debuginfo, r=wesleywiser
debuginfo: Generalize C++-like encoding for enums. The updated encoding should be able to handle niche layouts where more than one variant has fields (as introduced in #94075). The new encoding is more uniform as there is no structural difference between direct-tag, niche-tag, and no-tag layouts anymore. The only difference between those cases is that the "dataful" variant in a niche-tag enum will have a `(start, end)` pair denoting the tag range instead of a single value. The new encoding now also supports 128-bit tags, which occur in at least some standard library types. These tags are represented as `u64` pairs so that debuggers (which don't always have support for 128-bit integers) can reliably deal with them. The downside is that this adds quite a bit of complexity to the encoding and especially to the corresponding NatVis. The new encoding seems to increase the size of (x86_64-pc-windows-msvc) debuginfo by 10-15%. The size of binaries is not affected (release builds were built with `-Cdebuginfo=2`, numbers are in kilobytes): EXE | before | after | relative -- | -- | -- | -- cargo (debug) | 40453 | 40450 | +0% ripgrep (debug) | 10275 | 10273 | +0% cargo (release) | 16186 | 16185 | +0% ripgrep (release) | 4727 | 4726 | +0% PDB | before | after | relative -- | -- | -- | -- cargo (debug) | 236524 | 261412 | +11% ripgrep (debug) | 53140 | 59060 | +11% cargo (release) | 148516 | 169620 | +14% ripgrep (release) | 10676 | 11804 | +11% Given that the new encoding is more general, this is to be expected. Only platforms using C++-like debuginfo are affected -- which currently is only `*-pc-windows-msvc`. *TODO* - [x] Properly update documentation - [x] Add regression tests for new optimized enum layouts as introduced by #94075. r? `@wesleywiser`
2 parents 6ce7609 + 03b93d0 commit 4916e2b

File tree

23 files changed

+1118
-424
lines changed

23 files changed

+1118
-424
lines changed
 

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ macro_rules! return_if_di_node_created_in_meantime {
114114
}
115115

116116
/// Extract size and alignment from a TyAndLayout.
117+
#[inline]
117118
fn size_and_align_of<'tcx>(ty_and_layout: TyAndLayout<'tcx>) -> (Size, Align) {
118119
(ty_and_layout.size, ty_and_layout.align.abi)
119120
}

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 574 additions & 164 deletions
Large diffs are not rendered by default.

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_middle::{
1010
ty::{
1111
self,
1212
layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout},
13-
util::Discr,
1413
AdtDef, GeneratorSubsts, Ty, VariantDef,
1514
},
1615
};
@@ -90,8 +89,11 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
9089
cx,
9190
&compute_debuginfo_type_name(cx.tcx, enum_type_and_layout.ty, false),
9291
tag_base_type(cx, enum_type_and_layout),
93-
&mut enum_adt_def.discriminants(cx.tcx).map(|(variant_index, discr)| {
94-
(discr, Cow::from(enum_adt_def.variant(variant_index).name.as_str()))
92+
enum_adt_def.discriminants(cx.tcx).map(|(variant_index, discr)| {
93+
let name = Cow::from(enum_adt_def.variant(variant_index).name.as_str());
94+
// Is there anything we can do to support 128-bit C-Style enums?
95+
let value = discr.val as u64;
96+
(name, value)
9597
}),
9698
containing_scope,
9799
),
@@ -152,7 +154,7 @@ fn build_enumeration_type_di_node<'ll, 'tcx>(
152154
cx: &CodegenCx<'ll, 'tcx>,
153155
type_name: &str,
154156
base_type: Ty<'tcx>,
155-
variants: &mut dyn Iterator<Item = (Discr<'tcx>, Cow<'tcx, str>)>,
157+
enumerators: impl Iterator<Item = (Cow<'tcx, str>, u64)>,
156158
containing_scope: &'ll DIType,
157159
) -> &'ll DIType {
158160
let is_unsigned = match base_type.kind() {
@@ -161,18 +163,15 @@ fn build_enumeration_type_di_node<'ll, 'tcx>(
161163
_ => bug!("build_enumeration_type_di_node() called with non-integer tag type."),
162164
};
163165

164-
let enumerator_di_nodes: SmallVec<Option<&'ll DIType>> = variants
165-
.map(|(discr, variant_name)| {
166-
unsafe {
167-
Some(llvm::LLVMRustDIBuilderCreateEnumerator(
168-
DIB(cx),
169-
variant_name.as_ptr().cast(),
170-
variant_name.len(),
171-
// FIXME: what if enumeration has i128 discriminant?
172-
discr.val as i64,
173-
is_unsigned,
174-
))
175-
}
166+
let enumerator_di_nodes: SmallVec<Option<&'ll DIType>> = enumerators
167+
.map(|(name, value)| unsafe {
168+
Some(llvm::LLVMRustDIBuilderCreateEnumerator(
169+
DIB(cx),
170+
name.as_ptr().cast(),
171+
name.len(),
172+
value as i64,
173+
is_unsigned,
174+
))
176175
})
177176
.collect();
178177

@@ -247,23 +246,27 @@ fn build_enumeration_type_di_node<'ll, 'tcx>(
247246
/// and a DW_TAG_member for each field (but not the discriminant).
248247
fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
249248
cx: &CodegenCx<'ll, 'tcx>,
250-
enum_type: Ty<'tcx>,
249+
enum_type_and_layout: TyAndLayout<'tcx>,
251250
enum_type_di_node: &'ll DIType,
252251
variant_index: VariantIdx,
253252
variant_def: &VariantDef,
254253
variant_layout: TyAndLayout<'tcx>,
255254
) -> &'ll DIType {
256-
debug_assert_eq!(variant_layout.ty, enum_type);
255+
debug_assert_eq!(variant_layout.ty, enum_type_and_layout.ty);
257256

258257
type_map::build_type_with_children(
259258
cx,
260259
type_map::stub(
261260
cx,
262261
Stub::Struct,
263-
UniqueTypeId::for_enum_variant_struct_type(cx.tcx, enum_type, variant_index),
262+
UniqueTypeId::for_enum_variant_struct_type(
263+
cx.tcx,
264+
enum_type_and_layout.ty,
265+
variant_index,
266+
),
264267
variant_def.name.as_str(),
265268
// NOTE: We use size and align of enum_type, not from variant_layout:
266-
cx.size_and_align_of(enum_type),
269+
size_and_align_of(enum_type_and_layout),
267270
Some(enum_type_di_node),
268271
DIFlags::FlagZero,
269272
),
@@ -290,9 +293,9 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
290293
type_di_node(cx, field_layout.ty),
291294
)
292295
})
293-
.collect()
296+
.collect::<SmallVec<_>>()
294297
},
295-
|cx| build_generic_type_param_di_nodes(cx, enum_type),
298+
|cx| build_generic_type_param_di_nodes(cx, enum_type_and_layout.ty),
296299
)
297300
.di_node
298301
}
@@ -398,6 +401,19 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
398401
.di_node
399402
}
400403

404+
#[derive(Copy, Clone)]
405+
enum DiscrResult {
406+
NoDiscriminant,
407+
Value(u128),
408+
Range(u128, u128),
409+
}
410+
411+
impl DiscrResult {
412+
fn opt_single_val(&self) -> Option<u128> {
413+
if let Self::Value(d) = *self { Some(d) } else { None }
414+
}
415+
}
416+
401417
/// Returns the discriminant value corresponding to the variant index.
402418
///
403419
/// Will return `None` if there is less than two variants (because then the enum won't have)
@@ -407,30 +423,38 @@ fn compute_discriminant_value<'ll, 'tcx>(
407423
cx: &CodegenCx<'ll, 'tcx>,
408424
enum_type_and_layout: TyAndLayout<'tcx>,
409425
variant_index: VariantIdx,
410-
) -> Option<u64> {
426+
) -> DiscrResult {
411427
match enum_type_and_layout.layout.variants() {
412-
&Variants::Single { .. } => None,
413-
&Variants::Multiple { tag_encoding: TagEncoding::Direct, .. } => Some(
414-
enum_type_and_layout.ty.discriminant_for_variant(cx.tcx, variant_index).unwrap().val
415-
as u64,
428+
&Variants::Single { .. } => DiscrResult::NoDiscriminant,
429+
&Variants::Multiple { tag_encoding: TagEncoding::Direct, .. } => DiscrResult::Value(
430+
enum_type_and_layout.ty.discriminant_for_variant(cx.tcx, variant_index).unwrap().val,
416431
),
417432
&Variants::Multiple {
418433
tag_encoding: TagEncoding::Niche { ref niche_variants, niche_start, dataful_variant },
419434
tag,
420435
..
421436
} => {
422437
if variant_index == dataful_variant {
423-
None
438+
let valid_range = enum_type_and_layout
439+
.for_variant(cx, variant_index)
440+
.largest_niche
441+
.as_ref()
442+
.unwrap()
443+
.valid_range;
444+
445+
let min = valid_range.start.min(valid_range.end);
446+
let min = tag.size(cx).truncate(min);
447+
448+
let max = valid_range.start.max(valid_range.end);
449+
let max = tag.size(cx).truncate(max);
450+
451+
DiscrResult::Range(min, max)
424452
} else {
425453
let value = (variant_index.as_u32() as u128)
426454
.wrapping_sub(niche_variants.start().as_u32() as u128)
427455
.wrapping_add(niche_start);
428456
let value = tag.size(cx).truncate(value);
429-
// NOTE(eddyb) do *NOT* remove this assert, until
430-
// we pass the full 128-bit value to LLVM, otherwise
431-
// truncation will be silent and remain undetected.
432-
assert_eq!(value as u64 as u128, value);
433-
Some(value as u64)
457+
DiscrResult::Value(value)
434458
}
435459
}
436460
}

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
8888
variant_name: Cow::from(enum_adt_def.variant(variant_index).name.as_str()),
8989
variant_struct_type_di_node: super::build_enum_variant_struct_type_di_node(
9090
cx,
91-
enum_type,
91+
enum_type_and_layout,
9292
enum_type_di_node,
9393
variant_index,
9494
enum_adt_def.variant(variant_index),
@@ -413,7 +413,13 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
413413
enum_type_and_layout.size.bits(),
414414
enum_type_and_layout.align.abi.bits() as u32,
415415
Size::ZERO.bits(),
416-
discr_value.map(|v| cx.const_u64(v)),
416+
discr_value.opt_single_val().map(|value| {
417+
// NOTE(eddyb) do *NOT* remove this assert, until
418+
// we pass the full 128-bit value to LLVM, otherwise
419+
// truncation will be silent and remain undetected.
420+
assert_eq!(value as u64 as u128, value);
421+
cx.const_u64(value as u64)
422+
}),
417423
DIFlags::FlagZero,
418424
variant_member_info.variant_struct_type_di_node,
419425
)

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub(super) enum UniqueTypeId<'tcx> {
4747
VariantPart(Ty<'tcx>, private::HiddenZst),
4848
/// The ID for the artificial struct type describing a single enum variant.
4949
VariantStructType(Ty<'tcx>, VariantIdx, private::HiddenZst),
50+
/// The ID for the additional wrapper struct type describing an enum variant in CPP-like mode.
51+
VariantStructTypeCppLikeWrapper(Ty<'tcx>, VariantIdx, private::HiddenZst),
5052
/// The ID of the artificial type we create for VTables.
5153
VTableTy(Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>, private::HiddenZst),
5254
}
@@ -71,6 +73,15 @@ impl<'tcx> UniqueTypeId<'tcx> {
7173
UniqueTypeId::VariantStructType(enum_ty, variant_idx, private::HiddenZst)
7274
}
7375

76+
pub fn for_enum_variant_struct_type_wrapper(
77+
tcx: TyCtxt<'tcx>,
78+
enum_ty: Ty<'tcx>,
79+
variant_idx: VariantIdx,
80+
) -> Self {
81+
debug_assert_eq!(enum_ty, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), enum_ty));
82+
UniqueTypeId::VariantStructTypeCppLikeWrapper(enum_ty, variant_idx, private::HiddenZst)
83+
}
84+
7485
pub fn for_vtable_ty(
7586
tcx: TyCtxt<'tcx>,
7687
self_type: Ty<'tcx>,

‎compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,19 @@ extern "C" {
20792079
Ty: &'a DIType,
20802080
) -> &'a DIType;
20812081

2082+
pub fn LLVMRustDIBuilderCreateStaticMemberType<'a>(
2083+
Builder: &DIBuilder<'a>,
2084+
Scope: &'a DIDescriptor,
2085+
Name: *const c_char,
2086+
NameLen: size_t,
2087+
File: &'a DIFile,
2088+
LineNo: c_uint,
2089+
Ty: &'a DIType,
2090+
Flags: DIFlags,
2091+
val: Option<&'a Value>,
2092+
AlignInBits: u32,
2093+
) -> &'a DIDerivedType;
2094+
20822095
pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>(
20832096
Builder: &DIBuilder<'a>,
20842097
Scope: &'a DIScope,

‎compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathD
1818
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Mutability};
1919
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
2020
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
21-
use rustc_middle::ty::{self, ExistentialProjection, GeneratorSubsts, ParamEnv, Ty, TyCtxt};
22-
use rustc_target::abi::{Integer, TagEncoding, Variants};
21+
use rustc_middle::ty::{self, ExistentialProjection, ParamEnv, Ty, TyCtxt};
22+
use rustc_target::abi::Integer;
2323
use smallvec::SmallVec;
2424

25-
use std::borrow::Cow;
2625
use std::fmt::Write;
2726

2827
use crate::debuginfo::wants_c_like_enum_debuginfo;
@@ -98,7 +97,6 @@ fn push_debuginfo_type_name<'tcx>(
9897

9998
if let Some(ty_and_layout) = layout_for_cpp_like_fallback {
10099
msvc_enum_fallback(
101-
tcx,
102100
ty_and_layout,
103101
&|output, visited| {
104102
push_item_name(tcx, def.did(), true, output);
@@ -391,11 +389,10 @@ fn push_debuginfo_type_name<'tcx>(
391389
// Name will be "{closure_env#0}<T1, T2, ...>", "{generator_env#0}<T1, T2, ...>", or
392390
// "{async_fn_env#0}<T1, T2, ...>", etc.
393391
// In the case of cpp-like debuginfo, the name additionally gets wrapped inside of
394-
// an artificial `enum$<>` type, as defined in msvc_enum_fallback().
392+
// an artificial `enum2$<>` type, as defined in msvc_enum_fallback().
395393
if cpp_like_debuginfo && t.is_generator() {
396394
let ty_and_layout = tcx.layout_of(ParamEnv::reveal_all().and(t)).unwrap();
397395
msvc_enum_fallback(
398-
tcx,
399396
ty_and_layout,
400397
&|output, visited| {
401398
push_closure_or_generator_name(tcx, def_id, substs, true, output, visited);
@@ -428,58 +425,17 @@ fn push_debuginfo_type_name<'tcx>(
428425

429426
/// MSVC names enums differently than other platforms so that the debugging visualization
430427
// format (natvis) is able to understand enums and render the active variant correctly in the
431-
// debugger. For more information, look in `src/etc/natvis/intrinsic.natvis` and
432-
// `EnumMemberDescriptionFactor::create_member_descriptions`.
428+
// debugger. For more information, look in
429+
// rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs.
433430
fn msvc_enum_fallback<'tcx>(
434-
tcx: TyCtxt<'tcx>,
435431
ty_and_layout: TyAndLayout<'tcx>,
436432
push_inner: &dyn Fn(/*output*/ &mut String, /*visited*/ &mut FxHashSet<Ty<'tcx>>),
437433
output: &mut String,
438434
visited: &mut FxHashSet<Ty<'tcx>>,
439435
) {
440436
debug_assert!(!wants_c_like_enum_debuginfo(ty_and_layout));
441-
let ty = ty_and_layout.ty;
442-
443-
output.push_str("enum$<");
437+
output.push_str("enum2$<");
444438
push_inner(output, visited);
445-
446-
let variant_name = |variant_index| match ty.kind() {
447-
ty::Adt(adt_def, _) => {
448-
debug_assert!(adt_def.is_enum());
449-
Cow::from(adt_def.variant(variant_index).name.as_str())
450-
}
451-
ty::Generator(..) => GeneratorSubsts::variant_name(variant_index),
452-
_ => unreachable!(),
453-
};
454-
455-
if let Variants::Multiple {
456-
tag_encoding: TagEncoding::Niche { dataful_variant, .. },
457-
tag,
458-
variants,
459-
..
460-
} = &ty_and_layout.variants
461-
{
462-
let dataful_variant_layout = &variants[*dataful_variant];
463-
464-
// calculate the range of values for the dataful variant
465-
let dataful_discriminant_range =
466-
dataful_variant_layout.largest_niche().unwrap().valid_range;
467-
468-
let min = dataful_discriminant_range.start;
469-
let min = tag.size(&tcx).truncate(min);
470-
471-
let max = dataful_discriminant_range.end;
472-
let max = tag.size(&tcx).truncate(max);
473-
474-
let dataful_variant_name = variant_name(*dataful_variant);
475-
write!(output, ", {}, {}, {}", min, max, dataful_variant_name).unwrap();
476-
} else if let Variants::Single { index: variant_idx } = &ty_and_layout.variants {
477-
// Uninhabited enums can't be constructed and should never need to be visualized so
478-
// skip this step for them.
479-
if !ty_and_layout.abi.is_uninhabited() {
480-
write!(output, ", {}", variant_name(*variant_idx)).unwrap();
481-
}
482-
}
483439
push_close_angle_bracket(true, output);
484440
}
485441

‎compiler/rustc_index/src/vec.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ impl<I: Idx, T> IndexVec<I, T> {
172172
}
173173

174174
#[inline]
175-
pub fn indices(&self) -> impl DoubleEndedIterator<Item = I> + ExactSizeIterator + 'static {
175+
pub fn indices(
176+
&self,
177+
) -> impl DoubleEndedIterator<Item = I> + ExactSizeIterator + Clone + 'static {
176178
(0..self.len()).map(|n| I::new(n))
177179
}
178180

‎compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,30 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType(
924924
fromRust(Flags), unwrapDI<DIType>(Ty)));
925925
}
926926

927+
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticMemberType(
928+
LLVMRustDIBuilderRef Builder,
929+
LLVMMetadataRef Scope,
930+
const char *Name,
931+
size_t NameLen,
932+
LLVMMetadataRef File,
933+
unsigned LineNo,
934+
LLVMMetadataRef Ty,
935+
LLVMRustDIFlags Flags,
936+
LLVMValueRef val,
937+
uint32_t AlignInBits
938+
) {
939+
return wrap(Builder->createStaticMemberType(
940+
unwrapDI<DIDescriptor>(Scope),
941+
StringRef(Name, NameLen),
942+
unwrapDI<DIFile>(File),
943+
LineNo,
944+
unwrapDI<DIType>(Ty),
945+
fromRust(Flags),
946+
unwrap<llvm::ConstantInt>(val),
947+
AlignInBits
948+
));
949+
}
950+
927951
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateLexicalBlock(
928952
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
929953
LLVMMetadataRef File, unsigned Line, unsigned Col) {

‎src/etc/natvis/intrinsic.natvis

Lines changed: 181 additions & 68 deletions
Large diffs are not rendered by default.

‎src/etc/natvis/liballoc.natvis

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,4 @@
185185
</ArrayItems>
186186
</Expand>
187187
</Type>
188-
189-
<Type Name="alloc::borrow::Cow&lt;*&gt;">
190-
<DisplayString Condition="RUST$ENUM$DISR == 0x0">Borrowed({__0})</DisplayString>
191-
<DisplayString Condition="RUST$ENUM$DISR == 0x1">Owned({__0})</DisplayString>
192-
<Expand>
193-
<Item Name="[value]" ExcludeView="simple">__0</Item>
194-
</Expand>
195-
</Type>
196188
</AutoVisualizer>

‎src/test/codegen/async-fn-debug-awaitee-field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ async fn async_fn_test() {
1212
}
1313

1414
// NONMSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}",
15-
// MSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum$<async_fn_debug_awaitee_field::async_fn_test::async_fn_env$0>",
15+
// MSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_awaitee_field::async_fn_test::async_fn_env$0>",
1616
// CHECK: [[SUSPEND_STRUCT:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend0", scope: [[GEN]],
1717
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__awaitee", scope: [[SUSPEND_STRUCT]], {{.*}}, baseType: [[AWAITEE_TYPE:![0-9]*]],
1818
// NONMSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "GenFuture<async_fn_debug_awaitee_field::foo::{async_fn_env#0}>",
19-
// MSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "GenFuture<enum$<async_fn_debug_awaitee_field::foo::async_fn_env$0> >",
19+
// MSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "GenFuture<enum2$<async_fn_debug_awaitee_field::foo::async_fn_env$0> >",
2020

2121
fn main() {
2222
let _fn = async_fn_test();

‎src/test/codegen/async-fn-debug-msvc.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async fn async_fn_test() {
1616

1717
// FIXME: No way to reliably check the filename.
1818

19-
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum$<async_fn_debug_msvc::async_fn_test::async_fn_env$0>",
19+
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_msvc::async_fn_test::async_fn_env$0>",
2020
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant0", scope: [[GEN]],
2121
// For brevity, we only check the struct name and members of the last variant.
2222
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 11,
@@ -36,16 +36,17 @@ async fn async_fn_test() {
3636
// CHECK-SAME: )
3737
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant4", scope: [[GEN]],
3838
// CHECK-SAME: file: [[FILE]], line: 14,
39-
// CHECK-SAME: baseType: [[VARIANT:![0-9]*]]
39+
// CHECK-SAME: baseType: [[VARIANT_WRAPPER:![0-9]*]]
4040
// CHECK-NOT: flags: DIFlagArtificial
4141
// CHECK-SAME: )
42+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: [[VARIANT_WRAPPER]], file: !2, baseType: [[VARIANT:![0-9]*]],
4243
// CHECK: [[VARIANT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[GEN]],
4344
// CHECK-NOT: flags: DIFlagArtificial
4445
// CHECK-SAME: )
4546
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: [[VARIANT]]
4647
// CHECK-NOT: flags: DIFlagArtificial
4748
// CHECK-SAME: )
48-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "discriminant", scope: [[GEN]],
49+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "tag", scope: [[GEN]],
4950
// CHECK-NOT: flags: DIFlagArtificial
5051

5152
fn main() {

‎src/test/codegen/debug-vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "align", scope: ![[VTABLE_TY2]], {{.*}}, baseType: ![[USIZE]], size: {{64|32}}, align: {{64|32}}, offset: {{128|64}})
4747

4848
// NONMSVC: !DIGlobalVariable(name: "<debug_vtable::bar::{closure_env#0} as core::ops::function::FnOnce<(core::option::Option<&dyn core::ops::function::Fn<(), Output=()>>)>>::{vtable}"
49-
// MSVC: !DIGlobalVariable(name: "impl$<debug_vtable::bar::closure_env$0, core::ops::function::FnOnce<tuple$<enum$<core::option::Option<ref$<dyn$<core::ops::function::Fn<tuple$<>,assoc$<Output,tuple$<> > > > > >, {{.*}}, {{.*}}, Some> > > >::vtable$"
49+
// MSVC: !DIGlobalVariable(name: "impl$<debug_vtable::bar::closure_env$0, core::ops::function::FnOnce<tuple$<enum2$<core::option::Option<ref$<dyn$<core::ops::function::Fn<tuple$<>,assoc$<Output,tuple$<> > > > > > > > > >::vtable$"
5050

5151
// NONMSVC: !DIGlobalVariable(name: "<debug_vtable::generic_closure::{closure_env#0}<bool> as core::ops::function::FnOnce<()>>::{vtable}"
5252
// MSVC: !DIGlobalVariable(name: "impl$<debug_vtable::generic_closure::closure_env$0<bool>, core::ops::function::FnOnce<tuple$<> > >::vtable$

‎src/test/codegen/generator-debug-msvc.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
2020

2121
// FIXME: No way to reliably check the filename.
2222

23-
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum$<generator_debug_msvc::generator_test::generator_env$0>"
23+
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<generator_debug_msvc::generator_test::generator_env$0>"
2424
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant0", scope: [[GEN]],
2525
// For brevity, we only check the struct name and members of the last variant.
2626
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 14,
@@ -40,16 +40,18 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
4040
// CHECK-SAME: )
4141
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant4", scope: [[GEN]],
4242
// CHECK-SAME: file: [[FILE]], line: 17,
43-
// CHECK-SAME: baseType: [[VARIANT:![0-9]*]]
43+
// CHECK-SAME: baseType: [[VARIANT_WRAPPER:![0-9]*]]
4444
// CHECK-NOT: flags: DIFlagArtificial
4545
// CHECK-SAME: )
46+
// CHECK: [[VARIANT_WRAPPER]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Variant4", scope: [[GEN]],
47+
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "value", scope: [[VARIANT_WRAPPER]], {{.*}}, baseType: [[VARIANT:![0-9]*]],
4648
// CHECK: [[VARIANT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[GEN]],
4749
// CHECK-NOT: flags: DIFlagArtificial
4850
// CHECK-SAME: )
4951
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: [[VARIANT]]
5052
// CHECK-NOT: flags: DIFlagArtificial
5153
// CHECK-SAME: )
52-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "discriminant", scope: [[GEN]],
54+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "tag", scope: [[GEN]],
5355
// CHECK-NOT: flags: DIFlagArtificial
5456

5557
fn main() {

‎src/test/debuginfo/generator-objects.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,26 @@
4141

4242
// cdb-command: g
4343
// cdb-command: dx b
44-
// cdb-check: b : Unresumed [Type: enum$<generator_objects::main::generator_env$0>]
45-
// cdb-check: [variant] : Unresumed
44+
// cdb-check: b : Unresumed [Type: enum2$<generator_objects::main::generator_env$0>]
4645
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *]
4746

4847
// cdb-command: g
4948
// cdb-command: dx b
50-
// cdb-check: b : Suspend0 [Type: enum$<generator_objects::main::generator_env$0>]
51-
// cdb-check: [variant] : Suspend0
49+
// cdb-check: b : Suspend0 [Type: enum2$<generator_objects::main::generator_env$0>]
5250
// cdb-check: [+0x[...]] c : 6 [Type: int]
5351
// cdb-check: [+0x[...]] d : 7 [Type: int]
5452
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *]
5553

5654
// cdb-command: g
5755
// cdb-command: dx b
58-
// cdb-check: b : Suspend1 [Type: enum$<generator_objects::main::generator_env$0>]
59-
// cdb-check: [variant] : Suspend1
56+
// cdb-check: b : Suspend1 [Type: enum2$<generator_objects::main::generator_env$0>]
6057
// cdb-check: [+0x[...]] c : 7 [Type: int]
6158
// cdb-check: [+0x[...]] d : 8 [Type: int]
6259
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *]
6360

6461
// cdb-command: g
6562
// cdb-command: dx b
66-
// cdb-check: b : Returned [Type: enum$<generator_objects::main::generator_env$0>]
67-
// cdb-check: [<Raw View>] [Type: enum$<generator_objects::main::generator_env$0>]
68-
// cdb-check: [variant] : Returned
63+
// cdb-check: b : Returned [Type: enum2$<generator_objects::main::generator_env$0>]
6964
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *]
7065

7166
#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)]

‎src/test/debuginfo/msvc-pretty-enums.rs

Lines changed: 179 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,141 @@
44
// cdb-command: g
55

66
// cdb-command: dx a
7-
// cdb-check:a : Some({...}) [Type: enum$<core::option::Option<msvc_pretty_enums::CStyleEnum>, 2, 16, Some>]
8-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<msvc_pretty_enums::CStyleEnum>, 2, 16, Some>]
9-
// cdb-check: [variant] : Some
7+
// cdb-check:a : Some [Type: enum2$<core::option::Option<msvc_pretty_enums::CStyleEnum> >]
108
// cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum]
119

1210
// cdb-command: dx b
13-
// cdb-check:b : None [Type: enum$<core::option::Option<msvc_pretty_enums::CStyleEnum>, 2, 16, Some>]
14-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<msvc_pretty_enums::CStyleEnum>, 2, 16, Some>]
15-
// cdb-check: [variant] : None
11+
// cdb-check:b : None [Type: enum2$<core::option::Option<msvc_pretty_enums::CStyleEnum> >]
1612

1713
// cdb-command: dx c
18-
// cdb-check:c : Tag1 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
19-
// cdb-check: [<Raw View>] [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
20-
// cdb-check: [variant] : Tag1
14+
// cdb-check:c : Tag1 [Type: enum2$<msvc_pretty_enums::NicheLayoutEnum>]
2115

2216
// cdb-command: dx d
23-
// cdb-check:d : Data({...}) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
24-
// cdb-check: [<Raw View>] [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
25-
// cdb-check: [variant] : Data
17+
// cdb-check:d : Data [Type: enum2$<msvc_pretty_enums::NicheLayoutEnum>]
2618
// cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
2719

2820
// cdb-command: dx e
29-
// cdb-check:e : Tag2 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
30-
// cdb-check: [<Raw View>] [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
31-
// cdb-check: [variant] : Tag2
21+
// cdb-check:e : Tag2 [Type: enum2$<msvc_pretty_enums::NicheLayoutEnum>]
3222

3323
// cdb-command: dx f
34-
// cdb-check:f : Some({...}) [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
35-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
36-
// cdb-check: [variant] : Some
24+
// cdb-check:f : Some [Type: enum2$<core::option::Option<ref$<u32> > >]
3725
// cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *]
3826

3927
// cdb-command: dx g
40-
// cdb-check:g : None [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
41-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
42-
// cdb-check: [variant] : None
28+
// cdb-check:g : None [Type: enum2$<core::option::Option<ref$<u32> > >]
4329

4430
// cdb-command: dx h
45-
// cdb-check:h : Some [Type: enum$<core::option::Option<u32> >]
46-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<u32> >]
47-
// cdb-check: [variant] : Some
31+
// cdb-check:h : Some [Type: enum2$<core::option::Option<u32> >]
4832
// cdb-check: [+0x004] __0 : 0xc [Type: unsigned int]
4933

5034
// cdb-command: dx i
51-
// cdb-check:i : None [Type: enum$<core::option::Option<u32> >]
52-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<u32> >]
53-
// cdb-check: [variant] : None
35+
// cdb-check:i : None [Type: enum2$<core::option::Option<u32> >]
5436

5537
// cdb-command: dx j
5638
// cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
5739

5840
// cdb-command: dx k
59-
// cdb-check:k : Some({...}) [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
60-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
61-
// cdb-check: [variant] : Some
41+
// cdb-check:k : Some [Type: enum2$<core::option::Option<alloc::string::String> >]
6242
// cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String]
6343

6444
// cdb-command: dx l
65-
// cdb-check:l : Ok [Type: enum$<core::result::Result<u32,enum$<msvc_pretty_enums::Empty> >, Ok>]
66-
// cdb-check: [<Raw View>] [Type: enum$<core::result::Result<u32,enum$<msvc_pretty_enums::Empty> >, Ok>]
67-
// cdb-check: [variant] : Ok
45+
// cdb-check:l : Ok [Type: enum2$<core::result::Result<u32,enum2$<msvc_pretty_enums::Empty> > >]
6846
// cdb-check: [+0x000] __0 : 0x2a [Type: unsigned int]
6947

48+
// cdb-command: dx niche128_some
49+
// cdb-check: niche128_some : Some [Type: enum2$<core::option::Option<core::num::nonzero::NonZeroI128> >]
50+
// Note: we can't actually read the value of the field because CDB cannot handle 128 bit integers.
51+
// cdb-check: [+0x000] __0 [...] [Type: core::num::nonzero::NonZeroI128]
52+
53+
// cdb-command: dx niche128_none
54+
// cdb-check: niche128_none : None [Type: enum2$<core::option::Option<core::num::nonzero::NonZeroI128> >]
55+
56+
// cdb-command: dx wrapping_niche128_dataful
57+
// cdb-check: wrapping_niche128_dataful : X [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
58+
// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128]
59+
60+
// cdb-command: dx wrapping_niche128_none1
61+
// cdb-check: wrapping_niche128_none1 : Y [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
62+
// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128]
63+
64+
// cdb-command: dx wrapping_niche128_none2
65+
// cdb-check: wrapping_niche128_none2 : Z [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
66+
// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128]
67+
68+
// cdb-command: dx direct_tag_128_a,d
69+
// cdb-check: direct_tag_128_a,d : A [Type: enum2$<msvc_pretty_enums::DirectTag128>]
70+
// cdb-check: [+0x[...]] __0 : 42 [Type: unsigned int]
71+
72+
// cdb-command: dx direct_tag_128_b,d
73+
// cdb-check: direct_tag_128_b,d : B [Type: enum2$<msvc_pretty_enums::DirectTag128>]
74+
// cdb-check: [+0x[...]] __0 : 137 [Type: unsigned int]
75+
76+
// cdb-command: dx niche_w_fields_1_some,d
77+
// cdb-check: niche_w_fields_1_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields1>]
78+
// cdb-check: [+0x[...]] __0 : 0x[...] : 77 [Type: unsigned char *]
79+
// cdb-check: [+0x[...]] __1 : 7 [Type: unsigned int]
80+
81+
// cdb-command: dx niche_w_fields_1_none,d
82+
// cdb-check: niche_w_fields_1_none,d : B [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields1>]
83+
// cdb-check: [+0x[...]] __0 : 99 [Type: unsigned int]
84+
85+
// cdb-command: dx niche_w_fields_2_some,d
86+
// cdb-check: niche_w_fields_2_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields2>]
87+
// cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZeroU32]
88+
// cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64]
89+
90+
// cdb-command: dx niche_w_fields_2_none,d
91+
// cdb-check: niche_w_fields_2_none,d : B [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields2>]
92+
// cdb-check: [+0x[...]] __0 : 1000 [Type: unsigned __int64]
93+
94+
// cdb-command: dx niche_w_fields_3_some,d
95+
// cdb-check: niche_w_fields_3_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields3>]
96+
// cdb-check: [+0x[...]] __0 : 137 [Type: unsigned char]
97+
// cdb-check: [+0x[...]] __1 : true [Type: bool]
98+
99+
// cdb-command: dx niche_w_fields_3_niche1,d
100+
// cdb-check: niche_w_fields_3_niche1,d : B [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields3>]
101+
// cdb-check: [+0x[...]] __0 : 12 [Type: unsigned char]
102+
103+
// cdb-command: dx niche_w_fields_3_niche2,d
104+
// cdb-check: niche_w_fields_3_niche2,d : C [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields3>]
105+
// cdb-check: [+0x[...]] __0 : false [Type: bool]
106+
107+
// cdb-command: dx niche_w_fields_3_niche3,d
108+
// cdb-check: niche_w_fields_3_niche3,d : D [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields3>]
109+
// cdb-check: [+0x[...]] __0 : 34 [Type: unsigned char]
110+
111+
// cdb-command: dx niche_w_fields_3_niche4,d
112+
// cdb-check: niche_w_fields_3_niche4,d : E [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields3>]
113+
// cdb-check: [+0x[...]] __0 : 56 [Type: unsigned char]
114+
115+
// cdb-command: dx niche_w_fields_3_niche5,d
116+
// cdb-check: niche_w_fields_3_niche5,d : F [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields3>]
117+
118+
// cdb-command: dx -r3 niche_w_fields_std_result_ok,d
119+
// cdb-check: niche_w_fields_std_result_ok,d : Ok [Type: enum2$<core::result::Result<alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>,u64> >]
120+
// cdb-check: [+0x[...]] __0 [Type: alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>]
121+
// cdb-check: [+0x[...]] data_ptr : [...]
122+
// cdb-check: [+0x[...]] length : 3 [...]
123+
124+
// cdb-command: dx -r3 niche_w_fields_std_result_err,d
125+
// cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum2$<core::result::Result<alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>,u64> >]
126+
// cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64]
127+
128+
// cdb-command: dx -r2 arbitrary_discr1,d
129+
// cdb-check: arbitrary_discr1,d : Abc [Type: enum2$<msvc_pretty_enums::ArbitraryDiscr>]
130+
// cdb-check: [+0x[...]] __0 : 1234 [Type: unsigned int]
131+
132+
// cdb-command: dx -r2 arbitrary_discr2,d
133+
// cdb-check: arbitrary_discr2,d : Def [Type: enum2$<msvc_pretty_enums::ArbitraryDiscr>]
134+
// cdb-check: [+0x[...]] __0 : 5678 [Type: unsigned int]
135+
136+
#![feature(rustc_attrs)]
137+
#![feature(repr128)]
138+
#![feature(arbitrary_enum_discriminant)]
139+
140+
use std::num::{NonZeroI128, NonZeroU32};
141+
70142
pub enum CStyleEnum {
71143
Low = 2,
72144
High = 16,
@@ -80,6 +152,51 @@ pub enum NicheLayoutEnum {
80152

81153
pub enum Empty {}
82154

155+
// The following three types will use a niche layout once
156+
// https://github.com/rust-lang/rust/pull/94075 is merged:
157+
enum NicheLayoutWithFields1<'a> {
158+
A(&'a u8, u32),
159+
B(u32),
160+
}
161+
162+
enum NicheLayoutWithFields2 {
163+
A(NonZeroU32, u64),
164+
B(u64),
165+
}
166+
167+
enum NicheLayoutWithFields3 {
168+
A(u8, bool),
169+
B(u8),
170+
C(bool),
171+
D(u8),
172+
E(u8),
173+
F,
174+
}
175+
176+
#[rustc_layout_scalar_valid_range_start(340282366920938463463374607431768211454)]
177+
#[rustc_layout_scalar_valid_range_end(1)]
178+
#[repr(transparent)]
179+
struct Wrapping128(u128);
180+
181+
// #[rustc_layout(debug)]
182+
enum Wrapping128Niche {
183+
X(Wrapping128),
184+
Y,
185+
Z,
186+
}
187+
188+
#[repr(i128)]
189+
enum DirectTag128 {
190+
A(u32),
191+
B(u32),
192+
}
193+
194+
#[repr(u32)]
195+
enum ArbitraryDiscr {
196+
Abc(u32) = 1000,
197+
Def(u32) = 5000_000,
198+
}
199+
83200
fn main() {
84201
let a = Some(CStyleEnum::Low);
85202
let b = Option::<CStyleEnum>::None;
@@ -93,6 +210,35 @@ fn main() {
93210
let j = CStyleEnum::High;
94211
let k = Some("IAMA optional string!".to_string());
95212
let l = Result::<u32, Empty>::Ok(42);
213+
let niche128_some = Some(NonZeroI128::new(123456).unwrap());
214+
let niche128_none: Option<NonZeroI128> = None;
215+
216+
let wrapping_niche128_dataful =
217+
unsafe { Wrapping128Niche::X(Wrapping128(340282366920938463463374607431768211454)) };
218+
let wrapping_niche128_none1 = Wrapping128Niche::Y;
219+
let wrapping_niche128_none2 = Wrapping128Niche::Z;
220+
221+
let direct_tag_128_a = DirectTag128::A(42);
222+
let direct_tag_128_b = DirectTag128::B(137);
223+
224+
let niche_w_fields_1_some = NicheLayoutWithFields1::A(&77, 7);
225+
let niche_w_fields_1_none = NicheLayoutWithFields1::B(99);
226+
227+
let niche_w_fields_2_some = NicheLayoutWithFields2::A(NonZeroU32::new(800).unwrap(), 900);
228+
let niche_w_fields_2_none = NicheLayoutWithFields2::B(1000);
229+
230+
let niche_w_fields_3_some = NicheLayoutWithFields3::A(137, true);
231+
let niche_w_fields_3_niche1 = NicheLayoutWithFields3::B(12);
232+
let niche_w_fields_3_niche2 = NicheLayoutWithFields3::C(false);
233+
let niche_w_fields_3_niche3 = NicheLayoutWithFields3::D(34);
234+
let niche_w_fields_3_niche4 = NicheLayoutWithFields3::E(56);
235+
let niche_w_fields_3_niche5 = NicheLayoutWithFields3::F;
236+
237+
let niche_w_fields_std_result_ok: Result<Box<[u8]>, u64> = Ok(vec![1, 2, 3].into());
238+
let niche_w_fields_std_result_err: Result<Box<[u8]>, u64> = Err(789);
239+
240+
let arbitrary_discr1 = ArbitraryDiscr::Abc(1234);
241+
let arbitrary_discr2 = ArbitraryDiscr::Def(5678);
96242

97243
zzz(); // #break
98244
}

‎src/test/debuginfo/msvc-scalarpair-params.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
// cdb-command: g
1919

2020
// cdb-command: dx o1
21-
// cdb-check:o1 : Some [Type: enum$<core::option::Option<u32> >]
22-
// cdb-check: [variant] : Some
21+
// cdb-check:o1 : Some [Type: enum2$<core::option::Option<u32> >]
2322
// cdb-check: [+0x004] __0 : 0x4d2 [Type: [...]]
2423
// cdb-command: dx o2
25-
// cdb-check:o2 : Some [Type: enum$<core::option::Option<u64> >]
26-
// cdb-check: [variant] : Some
24+
// cdb-check:o2 : Some [Type: enum2$<core::option::Option<u64> >]
2725
// cdb-check: [+0x008] __0 : 0x162e [Type: unsigned __int64]
2826

2927
// cdb-command: g
@@ -89,7 +87,7 @@ fn slice(s: &[u8]) {
8987
zzz(); // #break
9088
}
9189

92-
fn zzz() { }
90+
fn zzz() {}
9391

9492
fn main() {
9593
range(10..12, 20..30);

‎src/test/debuginfo/mutex.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@
2020
// cdb-check: [<Raw View>] [Type: core::cell::UnsafeCell<i32>]
2121

2222
//
23-
// cdb-command:dx lock,d
24-
// cdb-check:lock,d : Ok [Type: enum$<core::result::Result<std::sync::mutex::MutexGuard<i32>,enum$<std::sync::poison::TryLockError<std::sync::mutex::MutexGuard<i32> >, 0, 1, Poisoned> > >]
25-
// cdb-check: [variant] : Ok
23+
// cdb-command:dx _lock,d
24+
// cdb-check:_lock,d : Ok [Type: enum2$<core::result::Result<std::sync::mutex::MutexGuard<i32>,enum2$<std::sync::poison::TryLockError<std::sync::mutex::MutexGuard<i32> > > > >]
2625
// cdb-check: [...] __0 [Type: std::sync::mutex::MutexGuard<i32>]
2726

2827
use std::sync::Mutex;
2928

30-
#[allow(unused_variables)]
31-
fn main()
32-
{
29+
fn main() {
3330
let m = Mutex::new(0);
34-
let lock = m.try_lock();
31+
let _lock = m.try_lock();
32+
33+
println!("this line avoids an `Ambiguous symbol error` while setting the breakpoint");
34+
3535
zzz(); // #break
3636
}
3737

38+
#[inline(never)]
3839
fn zzz() {}

‎src/test/debuginfo/pretty-std.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
// gdb-command: print some_string
4040
// gdb-check:$8 = Some = {"IAMA "...}
4141

42-
4342
// === LLDB TESTS ==================================================================================
4443

4544
// lldb-command: run
@@ -65,7 +64,6 @@
6564
// lldb-command: print os_string
6665
// lldb-check:[...]$6 = "IAMA OS string 😃"[...]
6766

68-
6967
// === CDB TESTS ==================================================================================
7068

7169
// cdb-command: g
@@ -118,20 +116,17 @@
118116
// cdb-check: [chars] : "IAMA OS string [...]"
119117

120118
// cdb-command: dx some
121-
// cdb-check:some : Some [Type: enum$<core::option::Option<i16> >]
122-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<i16> >]
123-
// cdb-check: [variant] : Some
119+
// cdb-check:some : Some [Type: enum2$<core::option::Option<i16> >]
120+
// cdb-check: [<Raw View>] [Type: enum2$<core::option::Option<i16> >]
124121
// cdb-check: [+0x002] __0 : 8 [Type: short]
125122

126123
// cdb-command: dx none
127-
// cdb-check:none : None [Type: enum$<core::option::Option<i64> >]
128-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<i64> >]
129-
// cdb-check: [variant] : None
124+
// cdb-check:none : None [Type: enum2$<core::option::Option<i64> >]
125+
// cdb-check: [<Raw View>] [Type: enum2$<core::option::Option<i64> >]
130126

131127
// cdb-command: dx some_string
132-
// cdb-check:some_string : Some({...}) [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
133-
// cdb-check: [<Raw View>] [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
134-
// cdb-check: [variant] : Some
128+
// cdb-check:some_string : Some [Type: enum2$<core::option::Option<alloc::string::String> >]
129+
// cdb-check: [<Raw View>] [Type: enum2$<core::option::Option<alloc::string::String> >]
135130
// cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String]
136131

137132
// cdb-command: dx linkedlist
@@ -153,7 +148,6 @@ use std::collections::{LinkedList, VecDeque};
153148
use std::ffi::OsString;
154149

155150
fn main() {
156-
157151
// &[]
158152
let slice: &[i32] = &[0, 1, 2, 3];
159153

@@ -188,4 +182,6 @@ fn main() {
188182
zzz(); // #break
189183
}
190184

191-
fn zzz() { () }
185+
fn zzz() {
186+
()
187+
}

‎src/test/debuginfo/result-types.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
// cdb-command: g
88

99
// cdb-command: dx x,d
10-
// cdb-check:x,d : Ok [Type: enum$<core::result::Result<i32,str> >]
10+
// cdb-check:x,d : Ok [Type: enum2$<core::result::Result<i32,str> >]
1111
// cdb-check: [...] __0 : -3 [Type: int]
1212

1313
// cdb-command: dx y
14-
// cdb-check:y : Err [Type: enum$<core::result::Result<i32,str> >]
14+
// cdb-check:y : Err [Type: enum2$<core::result::Result<i32,str> >]
1515
// cdb-check: [...] __0 : "Some error message" [Type: str]
1616

17-
fn main()
18-
{
17+
fn main() {
1918
let x: Result<i32, &str> = Ok(-3);
2019
assert_eq!(x.is_ok(), true);
2120

@@ -25,4 +24,6 @@ fn main()
2524
zzz(); // #break.
2625
}
2726

28-
fn zzz() { () }
27+
fn zzz() {
28+
()
29+
}

‎src/test/debuginfo/type-names.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,51 +175,51 @@
175175
// 0-sized structs appear to be optimized away in some cases, so only check the structs that do
176176
// actually appear.
177177
// cdb-command:dv /t *_struct
178-
// cdb-check:struct type_names::GenericStruct<enum$<type_names::mod1::Enum2>,f64> mut_generic_struct = [...]
178+
// cdb-check:struct type_names::GenericStruct<enum2$<type_names::mod1::Enum2>,f64> mut_generic_struct = [...]
179179

180180
// ENUMS
181181
// cdb-command:dv /t *_enum_*
182-
// cdb-check:union enum$<type_names::Enum1> simple_enum_1 = [...]
183-
// cdb-check:union enum$<type_names::Enum1> simple_enum_2 = [...]
184-
// cdb-check:union enum$<type_names::mod1::Enum2> simple_enum_3 = [...]
185-
// cdb-check:union enum$<type_names::mod1::mod2::Enum3<type_names::mod1::Struct2> > generic_enum_1 = [...]
186-
// cdb-check:union enum$<type_names::mod1::mod2::Enum3<type_names::Struct1> > generic_enum_2 = [...]
182+
// cdb-check:union enum2$<type_names::Enum1> simple_enum_1 = [...]
183+
// cdb-check:union enum2$<type_names::Enum1> simple_enum_2 = [...]
184+
// cdb-check:union enum2$<type_names::mod1::Enum2> simple_enum_3 = [...]
185+
// cdb-check:union enum2$<type_names::mod1::mod2::Enum3<type_names::mod1::Struct2> > generic_enum_1 = [...]
186+
// cdb-check:union enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > generic_enum_2 = [...]
187187

188188
// TUPLES
189189
// cdb-command:dv /t tuple*
190-
// cdb-check:struct tuple$<u32,type_names::Struct1,enum$<type_names::mod1::mod2::Enum3<type_names::mod1::Struct2> > > tuple1 = [...]
191-
// cdb-check:struct tuple$<tuple$<type_names::Struct1,type_names::mod1::mod2::Struct3>,enum$<type_names::mod1::Enum2>,char> tuple2 = [...]
190+
// cdb-check:struct tuple$<u32,type_names::Struct1,enum2$<type_names::mod1::mod2::Enum3<type_names::mod1::Struct2> > > tuple1 = [...]
191+
// cdb-check:struct tuple$<tuple$<type_names::Struct1,type_names::mod1::mod2::Struct3>,enum2$<type_names::mod1::Enum2>,char> tuple2 = [...]
192192

193193
// BOX
194194
// cdb-command:dv /t box*
195195
// cdb-check:struct tuple$<alloc::boxed::Box<f32,alloc::alloc::Global>,i32> box1 = [...]
196-
// cdb-check:struct tuple$<alloc::boxed::Box<enum$<type_names::mod1::mod2::Enum3<f32> >,alloc::alloc::Global>,i32> box2 = [...]
196+
// cdb-check:struct tuple$<alloc::boxed::Box<enum2$<type_names::mod1::mod2::Enum3<f32> >,alloc::alloc::Global>,i32> box2 = [...]
197197

198198
// REFERENCES
199199
// cdb-command:dv /t *ref*
200200
// cdb-check:struct tuple$<ref$<type_names::Struct1>,i32> ref1 = [...]
201201
// cdb-check:struct tuple$<ref$<type_names::GenericStruct<char,type_names::Struct1> >,i32> ref2 = [...]
202202
// cdb-check:struct tuple$<ref_mut$<type_names::Struct1>,i32> mut_ref1 = [...]
203-
// cdb-check:struct tuple$<ref_mut$<type_names::GenericStruct<enum$<type_names::mod1::Enum2>,f64> >,i32> mut_ref2 = [...]
203+
// cdb-check:struct tuple$<ref_mut$<type_names::GenericStruct<enum2$<type_names::mod1::Enum2>,f64> >,i32> mut_ref2 = [...]
204204

205205
// RAW POINTERS
206206
// cdb-command:dv /t *_ptr*
207207
// cdb-check:struct tuple$<ptr_mut$<type_names::Struct1>,isize> mut_ptr1 = [...]
208208
// cdb-check:struct tuple$<ptr_mut$<isize>,isize> mut_ptr2 = [...]
209-
// cdb-check:struct tuple$<ptr_mut$<enum$<type_names::mod1::mod2::Enum3<type_names::Struct1> > >,isize> mut_ptr3 = [...]
209+
// cdb-check:struct tuple$<ptr_mut$<enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > >,isize> mut_ptr3 = [...]
210210
// cdb-check:struct tuple$<ptr_const$<type_names::Struct1>,isize> const_ptr1 = [...]
211211
// cdb-check:struct tuple$<ptr_const$<isize>,isize> const_ptr2 = [...]
212-
// cdb-check:struct tuple$<ptr_const$<enum$<type_names::mod1::mod2::Enum3<type_names::Struct1> > >,isize> const_ptr3 = [...]
212+
// cdb-check:struct tuple$<ptr_const$<enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > >,isize> const_ptr3 = [...]
213213

214214
// VECTORS
215215
// cdb-command:dv /t *vec*
216216
// cdb-check:struct tuple$<array$<type_names::Struct1,3>,i16> fixed_size_vec1 = [...]
217217
// cdb-check:struct tuple$<array$<usize,3>,i16> fixed_size_vec2 = [...]
218218
// cdb-check:struct alloc::vec::Vec<usize,alloc::alloc::Global> vec1 = [...]
219-
// cdb-check:struct alloc::vec::Vec<enum$<type_names::mod1::Enum2>,alloc::alloc::Global> vec2 = [...]
219+
// cdb-check:struct alloc::vec::Vec<enum2$<type_names::mod1::Enum2>,alloc::alloc::Global> vec2 = [...]
220220
// cdb-command:dv /t slice*
221221
// cdb-check:struct slice$<usize> slice1 = [...]
222-
// cdb-check:struct slice$<enum$<type_names::mod1::Enum2> > slice2 = [...]
222+
// cdb-check:struct slice$<enum2$<type_names::mod1::Enum2> > slice2 = [...]
223223

224224
// TRAITS
225225
// cdb-command:dv /t *_trait
@@ -238,16 +238,16 @@
238238
// cdb-check:struct tuple$<type_names::mod1::Struct2 (*)(type_names::GenericStruct<u16,u8>),usize> unsafe_fn_with_return_value = [...]
239239
// cdb-check:struct tuple$<type_names::Struct1 (*)(),usize> extern_c_fn_with_return_value = [...]
240240
// cdb-check:struct tuple$<usize (*)(f64),usize> rust_fn_with_return_value = [...]
241-
// cdb-check:struct tuple$<void (*)(enum$<core::result::Result<char,f64> >),usize> unsafe_fn = [...]
241+
// cdb-check:struct tuple$<void (*)(enum2$<core::result::Result<char,f64> >),usize> unsafe_fn = [...]
242242
// cdb-check:struct tuple$<void (*)(isize),usize> extern_c_fn = [...]
243-
// cdb-check:struct tuple$<void (*)(enum$<core::option::Option<isize> >,enum$<core::option::Option<ref$<type_names::mod1::Struct2> >, 1, [...], Some>),usize> rust_fn = [...]
243+
// cdb-check:struct tuple$<void (*)(enum2$<core::option::Option<isize> >,enum2$<core::option::Option<ref$<type_names::mod1::Struct2> > >),usize> rust_fn = [...]
244244
// cdb-command:dv /t *_function*
245245
// cdb-check:struct tuple$<isize (*)(ptr_const$<u8>, ...),usize> variadic_function = [...]
246246
// cdb-check:struct tuple$<type_names::mod1::mod2::Struct3 (*)(type_names::mod1::mod2::Struct3),usize> generic_function_struct3 = [...]
247247
// cdb-check:struct tuple$<isize (*)(isize),usize> generic_function_int = [...]
248248
// cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("rust_fn")
249249
// cdb-check:Return Type: void
250-
// cdb-check:Parameter Types: enum$<core::option::Option<isize> >,enum$<core::option::Option<ref$<type_names::mod1::Struct2> >, 1, [...], Some>
250+
// cdb-check:Parameter Types: enum2$<core::option::Option<isize> >,enum2$<core::option::Option<ref$<type_names::mod1::Struct2> > >
251251
// cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("rust_fn_with_return_value")
252252
// cdb-check:Return Type: usize
253253
// cdb-check:Parameter Types: f64

‎src/tools/compiletest/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
545545
stamp.add_path(&path);
546546
}
547547

548+
stamp.add_dir(&rust_src_dir.join("src/etc/natvis"));
549+
548550
stamp.add_dir(&config.run_lib_path);
549551

550552
if let Some(ref rustdoc_path) = config.rustdoc_path {

0 commit comments

Comments
 (0)
Please sign in to comment.