- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Open
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
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)
kotatsuyaki
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.