diff --git a/src/items/constant-items.md b/src/items/constant-items.md index bf315932f..258c0ce5d 100644 --- a/src/items/constant-items.md +++ b/src/items/constant-items.md @@ -89,6 +89,17 @@ m!(const _: () = ();); // const _: () = (); ``` +Unnamed constants are always [evaluated][const_eval] at compile-time to surface +panics. This happens even within an unused function: + +```rust,compile_fail +fn unused_generic_function() { + // A failing compile-time assertion + const _: () = assert!(usize::BITS == 0); +} +``` + +[const_eval]: ../const_eval.md [associated constant]: ../items/associated-items.md#associated-constants [constant value]: ../const_eval.md#constant-expressions [free]: ../glossary.md#free-item