-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Gate if-let guard feature #74566
Gate if-let guard feature #74566
Conversation
This comment has been minimized.
This comment has been minimized.
|
a7c36d6
to
4810d29
Compare
LGTM, letting @eddyb have final r+. |
Crater result in #74315 : #74315 (comment) There are real regressions here. This snippet now fails to compile when previously accepted: #[derive(PartialEq)]
struct Foo {
a: i32,
b: f32,
}
let f = Foo { a: 42, b: 0.0 };
match () {
() if f == Foo { a: 0, b: 0.0 } => {}
//~^ ERROR: struct literals are not allowed here
_ => {}
} But note that the if f == Foo { a: 0, b: 0.0 } {
//~^ ERROR: struct literals are not allowed here
} error: struct literals are not allowed here
--> src/lib.rs:14:13
|
14 | if f == Foo { a: 0, b: 0.0 } {
| ^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
14 | if f == (Foo { a: 0, b: 0.0 }) {
| ^ ^
error: aborting due to previous error I guess we have to accept this fate and fallback to previous |
1d29eb1
to
df96b4f
Compare
Updated. |
Shame. We could maybe change that in 2021? |
There are 12 regressed crates out of 113052 crates tested. Spurious:
Real regressions:
There are breakages when disallowing struct literals in |
This is Underspecified language semantics. On reference, match arm guard is Can I nominate this issue for T-lang or T-compiler? |
The reason unwrapped |
Yes, I agree there are no ambiguity in the correct code. |
This comment has been minimized.
This comment has been minimized.
Unlike if condition, match guard accepts struct literal.
This doesn't seem like something that should be changed in a PR - this is a breaking change to the language itself. Can we try to improve the diagnostic instead? |
I don't change that in this PR. I will open a new issue for discussing it. |
Can we merge this PR, @eddyb ? This PR in current state doesn't break old code. |
You may want to find a different reviewer, I know that eddyb is very behind on github notifications 😅 |
Thanks. I don't know what appropriate reviewers. I would wait a few days before finding another one. |
This seems to be a parsing change, so: |
@bors r+ |
📌 Commit ef50477 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Enhanced on #74315. That PR is in crater queue so I don't want to push to it.
Close #74232
cc #51114