Skip to content

Recursive const stability checks do not apply in const items #132536

Open
@RalfJung

Description

@RalfJung

All stable const fn in core/alloc/std are checked to ensure that they, transitively, do not use any unstable const features.

However, the same is not the case for const items. A stable fn can use array lengths, and a stable trait can have associated const, that use arbitrary unstable const features. That seems bad? I'm not entirely sure how to fix that though -- these items don't themselves have any stability, after all. They are just use in a large function (that may not even be a const fn).

One example where we are actually doing this is here:

buf: [u8; unsafe { CMSG_SPACE(SCM_MSG_LEN as u32) as usize }],

CMSG_SPACE is a const fn defined in libc. It is not subject to any recursive const stability checks.

Cc @rust-lang/wg-const-eval @compiler-errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-stabilityArea: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-const-evalWorking group: Const evaluation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions