Skip to content

Commit a2c9de4

Browse files
committed
Remove the explicit branch hint from const_panic
1 parent 37aa213 commit a2c9de4

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

library/core/src/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub macro const_panic {
195195
#[doc(hidden)]
196196
pub macro const_assert {
197197
($condition: expr, $const_msg:literal, $runtime_msg:literal, $($arg:tt)*) => {{
198-
if !$crate::intrinsics::likely($condition) {
198+
if !($condition) {
199199
$crate::panic::const_panic!($const_msg, $runtime_msg, $($arg)*)
200200
}
201201
}}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: -Copt-level=3
2+
#![crate_type = "lib"]
3+
#![feature(panic_internals, rustc_allow_const_fn_unstable, const_eval_select, core_intrinsics)]
4+
5+
#[no_mangle]
6+
pub fn test_assert(x: bool) {
7+
core::panic::const_assert!(x, "", "",);
8+
}
9+
10+
// check that assert! emits branch weights
11+
12+
// CHECK-LABEL: @test_assert(
13+
// CHECK: br i1 %x, label %bb2, label %bb1, !prof ![[NUM:[0-9]+]]
14+
// CHECK: bb1:
15+
// CHECK: panic
16+
// CHECK: bb2:
17+
// CHECK: ret void
18+
// CHECK: ![[NUM]] = !{!"branch_weights", {{(!"expected", )?}}i32 2000, i32 1}

0 commit comments

Comments
 (0)