Skip to content

Commit dd48e56

Browse files
committed
tests: Test line number in debuginfo for diverging function calls
1 parent 855e0fe commit dd48e56

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/// Make sure that line debuginfo is correct for diverging calls under certain
2+
/// conditions. In particular we want to ensure that the line number is never
3+
/// 0, but we check the absence of 0 by looking for the expected exact line
4+
/// numbers. Regression test for <https://github.com/rust-lang/rust/issues/59558>.
5+
6+
//@ compile-flags: -g -Clto -Copt-level=0
7+
//@ no-prefer-dynamic
8+
9+
fn main() {
10+
if True == False {
11+
// unreachable
12+
// CHECK-DAG: [[UNREACHABLE_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], column: 9, scope:
13+
diverge();
14+
}
15+
16+
// CHECK-DAG: [[LAST_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], column: 5, scope:
17+
diverge();
18+
}
19+
20+
#[derive(PartialEq)]
21+
pub enum MyBool {
22+
True,
23+
False,
24+
}
25+
26+
use MyBool::*;
27+
28+
fn diverge() -> ! {
29+
panic!();
30+
}
31+
32+
// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[LAST_CALL_DBG]]
33+
// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[UNREACHABLE_CALL_DBG]]

0 commit comments

Comments
 (0)