Skip to content

Confusing error when defining constant #46336

@archer884

Description

@archer884

The following error results when attempting to create a constant from some non-constant function:

error[E0015]: calls in constants are limited to constant functions, struct and enum constructors

This may confuse rustaceans coming from languages where "constructors" are specially defined functions, since, in this case, it refers to Foo { field: Expression } rather than, say, Foo::new().

Better phrasing may be struct and enum literals?

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
on Nov 28, 2017
steveklabnik

steveklabnik commented on Nov 28, 2017

@steveklabnik
Member

SGTM

added
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
on Feb 12, 2018
krk

krk commented on Feb 19, 2018

@krk
Contributor

This issue seems to be fulfilled by the merge.

estebank

estebank commented on Feb 28, 2018

@estebank
Contributor

@krk that PR wasn't merged. Picking it up and adding a test for it would be enough.

added a commit that references this issue on Apr 20, 2018
b0df8f0
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-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@kennytm@archer884@krk@estebank

        Issue actions

          Confusing error when defining constant · Issue #46336 · rust-lang/rust