about summary refs log tree commit diff
path: root/tests/codegen-llvm/diverging-function-call-debuginfo.rs
diff options
context:
space:
mode:
authorFolkert de Vries <flokkievids@gmail.com>2025-08-03 10:44:41 +0000
committerGitHub <noreply@github.com>2025-08-03 10:44:41 +0000
commitc691374cc19d583103f3da5d655efb308a1648b9 (patch)
tree767496caef5b54e56f46a834d0d612705ce5e488 /tests/codegen-llvm/diverging-function-call-debuginfo.rs
parentdaa742afe5970109c1e15b391226f78087b10439 (diff)
parent49aa0ecc7b251003e61c38a56471195a2d3dabee (diff)
downloadrust-c691374cc19d583103f3da5d655efb308a1648b9.tar.gz
rust-c691374cc19d583103f3da5d655efb308a1648b9.zip
Merge pull request #1889 from rust-lang/rustc-pull
Rustc pull update
Diffstat (limited to 'tests/codegen-llvm/diverging-function-call-debuginfo.rs')
-rw-r--r--tests/codegen-llvm/diverging-function-call-debuginfo.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/codegen-llvm/diverging-function-call-debuginfo.rs b/tests/codegen-llvm/diverging-function-call-debuginfo.rs
new file mode 100644
index 00000000000..1a80fe1643d
--- /dev/null
+++ b/tests/codegen-llvm/diverging-function-call-debuginfo.rs
@@ -0,0 +1,38 @@
+/// Make sure that line debuginfo is correct for diverging calls under certain
+/// conditions. In particular we want to ensure that the line number is never
+/// 0, but we check the absence of 0 by looking for the expected exact line
+/// numbers. Regression test for <https://github.com/rust-lang/rust/issues/59558>.
+
+//@ compile-flags: -g -Clto -Copt-level=0
+//@ no-prefer-dynamic
+
+// First find the scope of both diverge() calls, namely this main() function.
+// CHECK-DAG: [[MAIN_SCOPE:![0-9]+]] = distinct !DISubprogram(name: "main", linkageName: {{.*}}diverging_function_call_debuginfo{{.*}}main{{.*}}
+fn main() {
+    if True == False {
+        // unreachable
+        // Then find the DILocation with the correct line number for this call ...
+        // CHECK-DAG: [[UNREACHABLE_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], {{.*}}scope: [[MAIN_SCOPE]]
+        diverge();
+    }
+
+    // ... and this call.
+    // CHECK-DAG: [[LAST_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], {{.*}}scope: [[MAIN_SCOPE]]
+    diverge();
+}
+
+#[derive(PartialEq)]
+pub enum MyBool {
+    True,
+    False,
+}
+
+use MyBool::*;
+
+fn diverge() -> ! {
+    panic!();
+}
+
+// Finally make sure both DILocations belong to each the respective diverge() call.
+// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[LAST_CALL_DBG]]
+// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[UNREACHABLE_CALL_DBG]]