rust-lang / rust-lang/rust

Recursive const stability checks do not apply in const items

Open
#132,536 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-const-eval A-stability C-bug T-compiler WG-const-eval
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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:
https://github.com/rust-lang/rust/blob/7f74c894b0e31f370b5321d94f2ca2830e1d30fd/library/std/src/sys/pal/unix/process/process_unix.rs#L813
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by investigating the recursive const stability checks and the const item use in library/std/src/sys/pal/unix/process/process_unix.rs around CMSG_SPACE. Determine how const items and associated consts should be checked, then verify that unstable const features are rejected transitively in these cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.