about summary refs log tree commit diff
path: root/tests/codegen/enum/enum-debug-niche-2.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-07 05:29:11 +0200
committerGitHub <noreply@github.com>2023-08-07 05:29:11 +0200
commitfe1c3a1a5e6afa5e8d342e5313aa3952bad30625 (patch)
treed778de75adf1b93a1a816fb0dc9d02a8360d281f /tests/codegen/enum/enum-debug-niche-2.rs
parent137177386b1d2c991a6f34bc0be57b5f4224159c (diff)
parentc81d3e23d1aa58571ce82de0af916cc7f3c9a1be (diff)
Rollup merge of #114230 - workingjubilee:codegen-tests-that-nest, r=Mark-Simulacrum
Nest other codegen test topics

This PR is like rust-lang/rust#114229 in that it mostly pushes codegen tests around, shoving them into their own directories, but because all of the changes are very simple cleanups I pulled them into a separate PR. The other PR might involve actually evaluating the correctness of the test after changes, but here it is mostly a matter of taste. The only "functional" change is deleting a few tests that... hinge on a version of LLVM that we don't support (as of rust-lang/rust#114148 anyways).

I considered a few different ways to group other topics but I feel the question of whether `tests/codegen/{vec,array,slice}` should exist is more subtle than these choices, as it might be better to group such related tests by other topics like bounds check elision, thus I avoided making it.
Diffstat (limited to 'tests/codegen/enum/enum-debug-niche-2.rs')
-rw-r--r--tests/codegen/enum/enum-debug-niche-2.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/codegen/enum/enum-debug-niche-2.rs b/tests/codegen/enum/enum-debug-niche-2.rs
new file mode 100644
index 00000000000..4b607d50574
--- /dev/null
+++ b/tests/codegen/enum/enum-debug-niche-2.rs
@@ -0,0 +1,50 @@
+// This tests that optimized enum debug info accurately reflects the enum layout.
+// This is ignored for the fallback mode on MSVC due to problems with PDB.
+
+//
+// ignore-msvc
+
+// compile-flags: -g -C no-prepopulate-passes
+
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}}
+
+#![feature(never_type)]
+
+#[derive(Copy, Clone)]
+pub struct Entity {
+    private: std::num::NonZeroU32,
+}
+
+#[derive(Copy, Clone, PartialEq, Eq)]
+pub struct Declaration;
+
+impl TypeFamily for Declaration {
+    type Base = Base;
+    type Placeholder = !;
+
+    fn intern_base_data(_: BaseKind<Self>) {}
+}
+
+#[derive(Copy, Clone)]
+pub struct Base;
+
+pub trait TypeFamily: Copy + 'static {
+    type Base: Copy;
+    type Placeholder: Copy;
+
+    fn intern_base_data(_: BaseKind<Self>);
+}
+
+#[derive(Copy, Clone)]
+pub enum BaseKind<F: TypeFamily> {
+    Named(Entity),
+    Placeholder(F::Placeholder),
+    Error,
+}
+
+pub fn main() {
+    let x = BaseKind::Error::<Declaration>;
+    let y = 7;
+}