Skip to content

Weird error message for non-const const fns #59611

Closed
@brson

Description

@brson
const fn foo() { panic!() }

fn main() { }
   Compiling playground v0.0.1 (/playground)
error: can only call other `min_const_fn` within a `min_const_fn`
 --> src/main.rs:1:18
  |
1 | const fn foo() { panic!() }
  |                  ^^^^^^^^
  |
  = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

The name min_const_fn seems meaningless to an end user. It should say something like "only call const functions within const functions."

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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