// SPDX-License-Identifier: GPL-2.012//! Build-time error.3//!4//! This crate provides a [const function][const-functions] `build_error`, which will panic in5//! compile-time if executed in [const context][const-context], and will cause a build error6//! if not executed at compile time and the optimizer does not optimise away the call.7//!8//! It is used by `build_assert!` in the kernel crate, allowing checking of9//! conditions that could be checked statically, but could not be enforced in10//! Rust yet (e.g. perform some checks in [const functions][const-functions], but those11//! functions could still be called in the runtime).12//!13//! For details on constant evaluation in Rust, please see the [Reference][const-eval].14//!15//! [const-eval]: https://doc.rust-lang.org/reference/const_eval.html16//! [const-functions]: https://doc.rust-lang.org/reference/const_eval.html#const-functions17//! [const-context]: https://doc.rust-lang.org/reference/const_eval.html#const-context1819#![no_std]2021/// Panics if executed in [const context][const-context], or triggers a build error if not.22///23/// [const-context]: https://doc.rust-lang.org/reference/const_eval.html#const-context24#[inline(never)]25#[cold]26#[export_name = "rust_build_error"]27#[track_caller]28pub const fn build_error(msg: &'static str) -> ! {29panic!("{}", msg);30}313233