Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 86dbcb5

Browse files
committed
Add codegen test.
1 parent e34caaf commit 86dbcb5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/codegen/inherit_overflow.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Zmir-enable-passes=+Inline,+ConstProp --crate-type lib
2+
// revisions: ASSERT NOASSERT
3+
//[ASSERT] compile-flags: -Coverflow-checks=on
4+
//[NOASSERT] compile-flags: -Coverflow-checks=off
5+
6+
// CHECK-LABEL: define{{.*}} @assertion
7+
// ASSERT: tail call void @_ZN4core9panicking5panic17h
8+
// NOASSERT: ret i8 0
9+
#[no_mangle]
10+
pub fn assertion() -> u8 {
11+
// Optimized MIR will replace this `CheckedBinaryOp` by `const (0, true)`.
12+
// Verify that codegen does or does not emit the panic.
13+
<u8 as std::ops::Add>::add(255, 1)
14+
}

0 commit comments

Comments
 (0)