Skip to content

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

Closed

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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    on Sep 22, 2018
  2. added
    A-frontendArea: Compiler frontend (errors, parsing and HIR)
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 22, 2018
  3. eddyb commented on Sep 22, 2018

    @eddyb
    Contributor

    Also, it should point at the Bar, I would think?

  4. oli-obk commented on Oct 1, 2018

    @oli-obk
    Contributor

    Pointing at the Bar is hard. It might be multiple bound spread out through where bounds and generics.

    We can change the message to "this generic parameter has nontrivial bounds which is not permitted in const fn"

  5. gnzlbg commented on Oct 1, 2018

    @gnzlbg
    ContributorAuthor

    FWIW I think that the bigger issue is that the message says that the feature is unstable, but doesn't mention how the feature is actually called. I guessed, and happened to guess just fine, but if min_const_fn becomes stable at some point, the error should properly mention which features users have to enable for this on nightly.

  6. added 3 commits that reference this issue on Feb 13, 2019
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-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