Skip to content

Commit 74a1d9b

Browse files
committed
explain that this does not allow any new code
1 parent e2ac2c6 commit 74a1d9b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

text/0000-constants-in-patterns.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
When a constant appears as a pattern, this is syntactic sugar for writing a pattern that corresponds to the constant's value by hand.
1010
This operation is only allowed when (a) the type of the constant implements `PartialEq`, and (b) the *value* of the constant being matched on has "structural equality", which means that `PartialEq` behaves the same way as that desugared pattern.
1111

12+
This RFC does not allow any new code, compared to what already builds on stable today.
13+
Its purpose is to explain the rules for constants in patterns in one coherent document,
14+
and to justify why we will start *rejecting* some code that currently works (see the [breaking changes](#breaking-changes) below).
15+
1216
# Motivation
1317
[motivation]: #motivation
1418

@@ -190,11 +194,11 @@ This RFC breaks code that compiles today, but only code that already emits a fut
190194
This only recently landed (Rust 1.75, currently in beta), and is not currently shown in dependencies.
191195
Crater found [three cases](https://github.com/rust-lang/rust/pull/116930#issuecomment-1784648989) across the ecosystem where `match` was used to compare function pointers;
192196
that code is buggy for the reasons mentioned above that make comparing function pointers unreliable.
193-
- Matching on floats triggers `illegal_floating_point_literal_pattern`. This triggers on *all* float matches, not just the forbidden ones.
197+
- Matching on floats triggers `illegal_floating_point_literal_pattern`. This triggers on *all* float matches, not just the ones forbidden by this RFC.
194198
It has been around for years, but is not currently shown in dependencies.
195199

196200
When the RFC gets accepted, the floating-point lint should be adjusted to only cover the cases we are really going to reject,
197-
and all of them should be shown in dependencies.
201+
and all of them should be shown in dependencies or directly turned into hard errors.
198202

199203
## Compiler/library cleanup
200204

0 commit comments

Comments
 (0)