Skip to content

Commit 18f3020

Browse files
committed
compare with RFC 1445
1 parent bd37599 commit 18f3020

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

patterns.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fn is_foo(x: i32) -> bool {
1414
However, that check has some loopholes, so e.g. `&T` can be used in a pattern no matter the `T`.
1515

1616
Any reference type const-pattern is compiled by [calling `PartialEq::eq`][compile-partial-eq] to compare the subject of the `match` with the constant. Const-patterns with other types (enum, struct, tuple, array) are treated as if the constant was inlined as a pattern (and the usual `match` tree is constructed).
17+
[RFC 1445](https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md) lays the groundwork for changing this in the future to always using `PartialEq::eq`, but no decision either way has been made yet.
1718

1819
[struct-eq]: https://github.com/rust-lang/rust/blob/2c28244cf0fc9868f55070e55b8f332d196eaf3f/src/librustc_mir_build/hair/pattern/const_to_pat.rs#L121
1920
[compile-partial-eq]: https://github.com/rust-lang/rust/blob/2c28244cf0fc9868f55070e55b8f332d196eaf3f/src/librustc_mir_build/build/matches/test.rs#L355

0 commit comments

Comments
 (0)