Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always fall back to PartialEq when a constant in a pattern is not recursively structural-eq #105750
Always fall back to PartialEq when a constant in a pattern is not recursively structural-eq #105750
Changes from all commits
8d00f76
ad424e6
87f9f99
2282258
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly the same behaviour as on master. We're behind a reference already, so we aren't even using the new code path in
test.rs
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a change in behaviour. If we have
Previously
THE_CONST
was destructured toDeref(Variant(Bar, CONST))
for an autogeneratedconst CONST: &Inner = &Inner;
Now it doesn't get destructured, but we directly see
THE_CONST
.A const of value
&Eek::Foo
would still get destructured toDeref(Variant(Foo, []))
If we had something like
We would get
Deref(Variant(Bar, Deref(Variant(None, []))
, before and after this PR.If you had a
Some
in there, we'd again useTHE_CONST
directly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, so the analysis here is value-driven, not type-driven?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe requiring recursive structural equality on the type of constants in order to expand them into patterns is not doable without breaking real code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can't say I am surprised.
This needs careful documentation though, to explain how this value analysis works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a more general case of the example already given, as it also works if you put something like a tuple or other builtin aggregate in between.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fishiest reasoning of all of them, but everything I've checked out already has had tests or was just a variant using a different aggregate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raw pointer constants were already not participating in exhaustiveness. Even if they are just an integer behind a raw pointer type. This thus has no effect on exhaustiveness and the runtime logic is already using PartialEq.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is already doing random things at runtime depending on opts. We are also already not using it for exhaustiveness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't emit an
unreachable_pattern
lint anymore, as we just treat the constant opaquely. Our exhaustiveness checks check for duplicate or already covered patterns, they don't realize that all patterns have already been covered and thus all remaining ones must be unreachable.self-contained playground link