Skip to content

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

Closed
@RalfJung

Description

@RalfJung

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

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

    Development

    No branches or pull requests

    Issue actions