Skip to content

feature adt_const_params does not work with &'static str anymore #138657

Open
@Arpadzein

Description

@Arpadzein

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions