Skip to content

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

@RalfJung

Description

@RalfJung
Member

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

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 27, 2024
added
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 27, 2024
added a commit that references this issue on Aug 31, 2024
ea5bb99
added a commit that references this issue on Aug 31, 2024
added a commit that references this issue on Oct 4, 2024
1d4224f
added a commit that references this issue on Oct 5, 2024
cb5bb13
added a commit that references this issue on Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @RalfJung@saethlin@rustbot

      Issue actions

        A const-unstable function cannot call other const-unstable functions gated under a language feature gate · Issue #129656 · rust-lang/rust