Skip to content

Incomplete warning min_const_fn for unstable trait bounds other than Sized #54469

Closed
@gnzlbg

Description

@gnzlbg
#![feature(min_const_fn)]
use std::marker::PhantomData;
pub struct Foo<T>(PhantomData<T>);
pub trait Bar {}
impl<T: Bar> Foo<T> {
    pub const fn foo() -> Self {
        Foo(PhantomData)
    }
}
fn main() {}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: trait bounds other than `Sized` on const fn parameters are unstable
 --> src/main.rs:5:6
  |
5 | impl<T: Bar> Foo<T> {
  |      ^

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

The error should mention which feature has to be enabled to make use of this. The feature is const_fn.

cc @oli-obk @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-frontendArea: Compiler frontend (errors, parsing and HIR)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