Skip to content

Commit

Permalink
rust: build_error: avoid core_panic
Browse files Browse the repository at this point in the history
Suggested-by: bjorn3 <[email protected]>
Suggested-by: Gary Guo <[email protected]>
Signed-off-by: Miguel Ojeda <[email protected]>
  • Loading branch information
ojeda committed Dec 2, 2021
1 parent 6837ae4 commit cb94e38
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions rust/build_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
//! functions could still be called in the runtime).

#![no_std]
#![feature(core_panic)]

/// Panics if executed in const context, or triggers a build error if not.
#[inline(never)]
#[cold]
#[no_mangle]
#[track_caller]
pub const fn build_error(msg: &'static str) -> ! {
// Could also be `panic!(msg)` to avoid using unstable feature `core_panic`,
// but it is not allowed in Rust 2021, while `panic!("{}", msg)` could not
// yet be used in const context.
core::panicking::panic(msg);
panic!("{}", msg);
}

#[cfg(CONFIG_RUST_BUILD_ASSERT_WARN)]
Expand Down

0 comments on commit cb94e38

Please sign in to comment.