Skip to content

Confusing error when defining constant #46336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
archer884 opened this issue Nov 28, 2017 · 3 comments
Closed

Confusing error when defining constant #46336

archer884 opened this issue Nov 28, 2017 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. WG-diagnostics Working group: Diagnostics

Comments

@archer884
Copy link

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?

@kennytm kennytm added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Nov 28, 2017
@steveklabnik
Copy link
Member

SGTM

@estebank estebank added the WG-diagnostics Working group: Diagnostics label Dec 7, 2017
@estebank estebank added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Feb 12, 2018
@krk
Copy link
Contributor

krk commented Feb 19, 2018

This issue seems to be fulfilled by the merge.

@estebank
Copy link
Contributor

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

kennytm added a commit to kennytm/rust that referenced this issue Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

5 participants