You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we allow matches to emit PartialEq::partial_eq calls, but don't enforce anything about those calls' constness. AFAICT the only PartialEq::partial_eq call that seems to be emitted is for &str, since ADTs seem to be decomposed into matches on their fields.
The problem here is that I thought the whole point of matches requiring PartialEquality of scrutinees is that we can conceptually think of const arms as PartialEq calls; the fact that we decompose them seems like an impl detail.
When a struct contains a &str, this ends up getting caught by the MIR constness checking, but this seems sub-optimal. OTOH, we can't just require everyone to derive_const(PartialEq, Eq) on their match scrutinees, since they may be relying on this behavior...
error[E0015]: cannot match on `str` in constant functions
--> src/lib.rs:12:9
|
12 | FOO => {}
| ^^^
|
= note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
The text was updated successfully, but these errors were encountered:
Currently we allow matches to emit
PartialEq::partial_eq
calls, but don't enforce anything about those calls'const
ness. AFAICT the onlyPartialEq::partial_eq
call that seems to be emitted is for&str
, since ADTs seem to be decomposed into matches on their fields.The problem here is that I thought the whole point of matches requiring
PartialEq
uality of scrutinees is that we can conceptually think of const arms asPartialEq
calls; the fact that we decompose them seems like an impl detail.When a struct contains a
&str
, this ends up getting caught by the MIR constness checking, but this seems sub-optimal. OTOH, we can't just require everyone toderive_const(PartialEq, Eq)
on their match scrutinees, since they may be relying on this behavior...What should we do 🤔
The text was updated successfully, but these errors were encountered: