Skip to content

Commit 74f7ad4

Browse files
committed
rust: build_error: improve documentation
This is part of the effort to minimize the differences of the `rust` branch with respect to mainline in order to eventually drop it. Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 790847c commit 74f7ad4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

rust/build_error.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22

33
//! Build-time error.
44
//!
5-
//! This crate provides a function `build_error`, which will panic in
6-
//! compile-time if executed in const context, and will cause a build error
7-
//! if not executed at compile time and the optimizer does not optimise away the
8-
//! call.
5+
//! This crate provides a [const function][const-functions] `build_error`, which will panic in
6+
//! compile-time if executed in [const context][const-context], and will cause a build error
7+
//! if not executed at compile time and the optimizer does not optimise away the call.
98
//!
109
//! It is used by `build_assert!` in the kernel crate, allowing checking of
1110
//! conditions that could be checked statically, but could not be enforced in
12-
//! Rust yet (e.g. perform some checks in const functions, but those
11+
//! Rust yet (e.g. perform some checks in [const functions][const-functions], but those
1312
//! functions could still be called in the runtime).
13+
//!
14+
//! For details on constant evaluation in Rust, please see the [Reference][const-eval].
15+
//!
16+
//! [const-eval]: https://doc.rust-lang.org/reference/const_eval.html
17+
//! [const-functions]: https://doc.rust-lang.org/reference/const_eval.html#const-functions
18+
//! [const-context]: https://doc.rust-lang.org/reference/const_eval.html#const-context
1419
1520
#![no_std]
1621

17-
/// Panics if executed in const context, or triggers a build error if not.
22+
/// Panics if executed in [const context][const-context], or triggers a build error if not.
23+
///
24+
/// [const-context]: https://doc.rust-lang.org/reference/const_eval.html#const-context
1825
#[inline(never)]
1926
#[cold]
2027
#[export_name = "rust_build_error"]

0 commit comments

Comments
 (0)