Skip to content

Commit 6b8cc0a

Browse files
committed
unresolved question around matching in const fn
1 parent ff2d059 commit 6b8cc0a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

text/0000-constants-in-patterns.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,13 @@ This RFC came out of discussions in a [t-lang design meeting](https://github.com
274274
# Unresolved questions
275275
[unresolved-questions]: #unresolved-questions
276276

277-
None at this time.
277+
- When a constant is used as a pattern in a `const fn`, what exactly should we require?
278+
Writing `x == C` would *not* be possible here since calling trait methods like `partial_eq` is not possible in `const fn` currently.
279+
In the future, writing `x == C` will likely require a `const impl PartialEq`.
280+
So by allowing `match x { C => ... }`, we are allowing uses of `C` that would not otherwise be permitted, which is exactly what the `PartialEq` check was intended to avoid.
281+
On the other hand, all this does is to allow at compile-time what could already be done at run-time, so maybe that's okay?
282+
Rejecting this would definitely be a breaking change; we currently don't even lint against these cases.
283+
Also see [this issue](https://github.com/rust-lang/rust/issues/119398).
278284

279285
# Future possibilities
280286
[future-possibilities]: #future-possibilities

0 commit comments

Comments
 (0)