mirror of https://github.com/rust-lang/reference
Adjust language to also cover named constants
Especially since it seems that there is no test in rust-lang/rust that covers the unamed constant case (even though the implementation covers it). https://github.com/rust-lang/rust/issues/93838#issuecomment-1430524383
This commit is contained in:
parent
86691a19e8
commit
021889f262
|
@ -89,10 +89,15 @@ m!(const _: () = (););
|
|||
// const _: () = ();
|
||||
```
|
||||
|
||||
Unnamed constants are always [evaluated][const_eval] at compile-time to surface
|
||||
## Evaluation
|
||||
|
||||
[Free][free] constants are always [evaluated][const_eval] at compile-time to surface
|
||||
panics. This happens even within an unused function:
|
||||
|
||||
```rust,compile_fail
|
||||
// Compile-time panic
|
||||
const PANIC: () = std::unimplemented!();
|
||||
|
||||
fn unused_generic_function<T>() {
|
||||
// A failing compile-time assertion
|
||||
const _: () = assert!(usize::BITS == 0);
|
||||
|
|
Loading…
Reference in New Issue