Skip to content

panic in constant evaluation while documenting default associated constant #149635

@bonzini

Description

@bonzini

Code

This is similar to #131625, but it used to work until recently:

#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct VMStateFlags(pub u32);
impl VMStateFlags {
    pub const VMS_POINTER: VMStateFlags = VMStateFlags(2);
}

#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct VMStateField {
    pub flags: VMStateFlags,
}

pub unsafe trait VMState {
    const BASE: VMStateField;
    const VARRAY_FLAG: VMStateFlags = {
        panic!("invalid type for variable-sized array");
    };
}

With rustdoc 1.91.1 and 1.92.0-beta.3 (f3f1244 2025-11-09), this works:

$ /usr/bin/rustdoc --edition=2021 --crate-name vmstate vmstate.rs -o doc

With rustdoc 1.93.0-nightly (83e49b7 2025-12-03), I get evaluation panicked.

Version it worked on

1.91.1

1.92.0-beta.3 (f3f1244 2025-11-09)

Version with regression

1.93.0-nightly (83e49b7 2025-12-03)

rustc --version --verbose:

rustc 1.93.0-nightly (83e49b75e 2025-12-03)
binary: rustc
commit-hash: 83e49b75e7daf827e4390ae0ccbcb0d0e2c96493
commit-date: 2025-12-03
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-fmtArea: `core::fmt`A-panicArea: Panicking machineryC-bugCategory: This is a bug.P-highHigh priorityS-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions