-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
In the Firefox style system we have this enum type and in the impl I'm adding a const, like so:
pub const INITIAL_VALUE: Self = Self::None;
That compiles fine. Then I'd like to add this function:
pub fn is_initial(&self) -> bool {
matches!(*self, Self::INITIAL_VALUE)
}
which results in:
error: could not evaluate constant pattern
--> servo/components/style/values/generics/grid.rs:770:25
|
770 | matches!(*self, Self::INITIAL_VALUE)
| ^^^^^^^^^^^^^^^^^^^
which makes no sense to me given that matches!(*self, Self::None)
compiles just fine.
(This is in a local mozilla-central build, and I think the compiler it uses is: rustc 1.39.0-nightly (6e19f3f 2019-09-06))
BTW, why is the type required in the const declaration? Why can't I just say:
pub const INITIAL_VALUE = Self::None;
It seems like the compiler should be able to deduce the type I wanted there...
IndigoLily
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.