Uh oh!
There was an error while loading. Please reload this page.
Suggest adding missing braces in const block pattern - #78173
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
3e567f0 to
0bf61fdCompareThere was a problem hiding this comment.
I think @petrochenkov and others wanted to avoid eating the keyword before checking if it's really an inline const. My first reaction was like ... but we're eating Unsafe right above. I'm not sure if there's another way to solve this problem and we could still rely on checking or if we just need to eat the keyword.
Anyway, would leave this to @petrochenkov
There was a problem hiding this comment.
The difference is that unsafe just modifies the block expression, whereas const needs to create the ExprKind::Const - but maybe it doesn't have to be too complicated shrug.
Uh oh!
There was an error while loading. Please reload this page.
spastorino
commented
Oct 21, 2020
Another thought, I've 2 PRs open for inline consts that changes in some way the code you're also touching. It may be good to land those first and base your work on those. |
camelid
commented
Oct 21, 2020
Yeah, I expected to have merge conflicts :) Weirdly, GitHub is reporting merge conflicts but bors is not. I think this issue has happened before; I’ll let T-infra take a look before I fix the conflicts so they can perhaps figure out the cause. |
b9e3545 to
31e18afComparecamelid
commented
Oct 21, 2020
Rebased. |
There was a problem hiding this comment.
The thing is that this:
letconst{"foo"} = "foo";is a totally valid statement (although it ICEs; see #78174). Perhaps we could give the old warning if it's just const and then = immediately after?
There was a problem hiding this comment.
I see, but, what do you expect that code to do?.
I'd expect an error anyway something like error[E0005]: refutable pattern in local binding: ``&_`` not covered.
There was a problem hiding this comment.
It's valid syntactically, not semantically. (And either way it shouldn't ICE.)
And yes, the error you suggested is correct; it's the one that occurs for let "foo" = "foo";: error[E0005]: refutable pattern in local binding: `&_` not covered
spastorino
commented
Oct 23, 2020
Now both of my follow up PRs are in and you would need to rebase again :). I think this is fine modulo the Anyway, this is fine by me but would leave this up to r? @petrochenkov |
petrochenkov
commented
Oct 24, 2020
a75494e to
19ec18bCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
Oct 24, 2020
@camelid So I suggest to parse In patterns we have the unary |
camelid
commented
Dec 18, 2020
I'm hoping to get to this at some point soon, I just need to understand this part of the codebase better. |
petrochenkov
commented
Dec 27, 2020
This can be split into two parts - one for expressions (which should be pretty much a copypaste of what |
Previously it would only suggest wrapping the code in braces in regular expressions; now it does it in patterns too.
Needed for range pattern parsing.
camelid
commented
Dec 31, 2020
Starting with a rebase. |
502fcec to
d9dfa89Comparecamelid
commented
Jan 1, 2021
@petrochenkov One issue with this is that prefix operators have high precedence, so the suggestion for wrapping the code in a block doesn't capture what it should: I'm not sure if there's a good way to resolve this because of the precedence of prefix operators. I haven't made many changes to the parser before, so I would appreciate some extra guidance! Thanks :) |
petrochenkov
commented
Jan 1, 2021
|
petrochenkov
commented
Feb 23, 2021
Closing due to inactivity. |
Previously it would only suggest wrapping the code in braces in regular expressions; now it does it in patterns too. This is a squashed rebase of rust-lang#78173
Previously it would only suggest wrapping the code in braces in regular expressions; now it does it in patterns too. This is a squashed rebase of rust-lang#78173
Previously it would only suggest wrapping the code in braces in regular expressions; now it does it in patterns too. This is a squashed rebase of rust-lang#78173
Previously it would only suggest wrapping the code in braces in regular expressions; now it does it in patterns too. This is a squashed rebase of rust-lang#78173
Fixes#78168.
Previously it would only suggest wrapping the code in braces in regular
expressions; now it does it in patterns too.
r? @spastorino