Open
Description
I have the following code:
pub trait Foo {
const BAR: ();
}
impl Foo for () {
const BAR: () = panic!("intentional PME");
}
While this is contrived, this pattern is used in real codebases to take advantage of post-monomorphization errors (PME's), for example here.
When running cargo doc
, rustdoc seems to try to evaluate the constant, and crashes:
$ cargo doc
Documenting tmp v0.1.0 (.../tmp)
error[E0080]: evaluation of constant value failed
--> src/lib.rs:6:21
|
6 | const BAR: () = panic!("intentional PME");
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'intentional PME', src/lib.rs:6:21
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
Miscellaneous
$ cargo version
cargo 1.78.0 (54d8815d0 2024-03-26)