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

A const-unstable function cannot call other const-unstable functions gated under a language feature gate #129656

Closed
RalfJung opened this issue Aug 27, 2024 · 0 comments · Fixed by #129659
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

RalfJung commented Aug 27, 2024

I expected this code to compile, but it does not:

#![feature(staged_api, f128)]
#![stable(feature = "rust_test", since = "1.0.0")]

#[unstable(feature = "f128", issue = "42")]
#[rustc_const_unstable(feature = "f128", issue = "42")]
const fn my_fun() {}

#[unstable(feature = "f128", issue = "42")]
#[rustc_const_unstable(feature = "f128", issue = "42")]
const fn my_fun2() {
    my_fun()
}

Renaming f128 to f128_const makes it compile, so somehow the issue must be related to the fact that f128 is a language feature gate. For regular library stability, we support also using a language feature as a library feature gate, but for const-stability that somehow does not work.

When this gets fixed, the f128_const and f16_const features (added in #129555) can be merged into the f128 and f16 features, respectively.

Cc @oli-obk

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 27, 2024
@saethlin saethlin added A-const-eval Area: Constant evaluation (MIR interpretation) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 27, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 31, 2024
…1-dead

const fn stability checking: also check declared language features

Fixes rust-lang#129656

`@oli-obk` I assume it is just an oversight that this didn't use `features().declared()`? Or is there a deep reason that this must only check `declared_lib_features`?
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 31, 2024
Rollup merge of rust-lang#129659 - RalfJung:const-fn-lang-feat, r=fee1-dead

const fn stability checking: also check declared language features

Fixes rust-lang#129656

`@oli-obk` I assume it is just an oversight that this didn't use `features().declared()`? Or is there a deep reason that this must only check `declared_lib_features`?
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 1, 2024
const fn stability checking: also check declared language features

Fixes rust-lang/rust#129656

`@oli-obk` I assume it is just an oversight that this didn't use `features().declared()`? Or is there a deep reason that this must only check `declared_lib_features`?
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Oct 4, 2024
…mdev

move f16/f128 const fn under f16/f128 feature gate

The `*_const` features were added to work around rust-lang#129656, which should not be needed any more.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 5, 2024
…mdev

move f16/f128 const fn under f16/f128 feature gate

The `*_const` features were added to work around rust-lang#129656, which should not be needed any more.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 5, 2024
Rollup merge of rust-lang#131256 - RalfJung:f16-f128-const, r=ibraheemdev

move f16/f128 const fn under f16/f128 feature gate

The `*_const` features were added to work around rust-lang#129656, which should not be needed any more.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Oct 10, 2024
move f16/f128 const fn under f16/f128 feature gate

The `*_const` features were added to work around rust-lang/rust#129656, which should not be needed any more.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
3 participants