Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Arpadzein opened this issue Mar 18, 2025 · 2 comments
Open

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

Arpadzein opened this issue Mar 18, 2025 · 2 comments
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Arpadzein
Copy link

Arpadzein commented Mar 18, 2025

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
@Arpadzein Arpadzein added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Mar 18, 2025
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 18, 2025
@BoxyUwU BoxyUwU removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 18, 2025
@BoxyUwU
Copy link
Member

BoxyUwU commented Mar 18, 2025

Hi, sorry for the confusion, we should probably improve the error message here. Usage of references in const generics has been split out into the unsized_const_params feature gate. If you use both adt_const_params and unsized_const_params at the same time your code should work as it used to.

@Arpadzein
Copy link
Author

Oh, thank you very much, and sorry for the misguided report ! It does work !

@fmease fmease added A-diagnostics Area: Messages for errors, warnings, and lints D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. A-const-generics Area: const generics (parameters and arguments) requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-untriaged Untriaged performance or correctness regression. labels Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants