rust-lang / rust-lang/rust

feature adt_const_params does not work with &'static str anymore

Open
#138,657 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-const-generics A-diagnostics D-terse requires-nightly T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I cannot use the feature adt_const_params with &'static str anymore. It works on toolchain nightly-2024-07-21 but not anymore on toolchain nightly-2024-07-22 (it is when rust went from version 1.81.0-nightly to 1.82.0-nightly). I don't know if I am doing something wrong, because I feel like someone else should have seen the problem, but I didn't find any issue on this

Code

I tried this code:

#![feature(adt_const_params)]
#![allow(incomplete_features)]

pub trait Trait<const NAME: &'static str> {}

I expected to see this happen: The code compiles

Instead, this happened: The code does not compile:

error[E0741]: `&'static str` can't be used as a const parameter type
 --> src/lib.rs:4:29
  |
4 | pub trait Trait<const NAME: &'static str> {}
  |                             ^^^^^^^^^^^^
Version it worked on

toolchain nightly-2024-07-21 (rust 1.81.0-nightly)

rustc -- version --verbose:

rustc 1.81.0-nightly (506985649 2024-07-20)
binary: rustc
commit-hash: 5069856495870486134dd2ca0b0e2516308c5c2a
commit-date: 2024-07-20
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
Version with regression

toolchain nightly-2024-07-22 (rust 1.82.0-nightly)

rustc --version --verbose:

rustc 1.82.0-nightly (92c6c0380 2024-07-21)
binary: rustc
commit-hash: 92c6c03805408a1a261b98013304e9bbf59ee428
commit-date: 2024-07-21
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 18.1.7

It does not work on latest nightly either

rustc --version --verbose:

rustc 1.87.0-nightly (43a2e9d2c 2025-03-17)
binary: rustc
commit-hash: 43a2e9d2c72db101f5fedac8b3acb78981b06bf2
commit-date: 2025-03-17
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

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 reproducing the minimal example in src/lib.rs with nightly-2024-07-21 and nightly-2024-07-22, then compare behavior through the latest nightly listed. Investigate the compiler change between commits 506985649 and 92c6c0380 affecting adt_const_params and const parameter type checking. Done means the example compiles again, or the issue is explained and the expected behavior is clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.