-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Catch stray {
in let-chains
#117770
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
Merged
Merged
Catch stray {
in let-chains
#117770
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0094238
Catch stray { in let-chains
sjwang05 9455259
Catch an edge case
sjwang05 a49368f
Correctly handle while-let-chains
sjwang05 f88cf02
Move unclosed delim errors to separate function
sjwang05 274824b
Fix `is_keyword_ahead` visibility
sjwang05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// issue #117766 | ||
|
||
#![feature(let_chains)] | ||
fn main() { | ||
if let () = () | ||
&& let () = () { //~ERROR: found a `{` in the middle of a let-chain | ||
&& let () = () | ||
{ | ||
} | ||
} | ||
|
||
fn quux() { | ||
while let () = () | ||
&& let () = () { //~ERROR: found a `{` in the middle of a let-chain | ||
&& let () = () | ||
{ | ||
} | ||
} | ||
|
||
fn foobar() { | ||
while false {} | ||
{ | ||
&& let () = () | ||
} | ||
|
||
fn fubar() { | ||
while false { | ||
{ | ||
&& let () = () | ||
} | ||
} | ||
|
||
fn qux() { | ||
let foo = false; | ||
match foo { | ||
_ if foo => { | ||
&& let () = () | ||
_ => {} | ||
} | ||
} | ||
|
||
fn foo() { | ||
{ | ||
&& let () = () | ||
} | ||
|
||
fn bar() { | ||
if false {} | ||
{ | ||
&& let () = () | ||
} | ||
|
||
fn baz() { | ||
if false { | ||
{ | ||
&& let () = () | ||
} | ||
} //~ERROR: this file contains an unclosed delimiter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
error: this file contains an unclosed delimiter | ||
--> $DIR/brace-in-let-chain.rs:58:54 | ||
| | ||
LL | fn main() { | ||
| - unclosed delimiter | ||
... | ||
LL | fn quux() { | ||
| - unclosed delimiter | ||
... | ||
LL | fn foobar() { | ||
| - unclosed delimiter | ||
... | ||
LL | fn fubar() { | ||
| - unclosed delimiter | ||
... | ||
LL | fn qux() { | ||
| - unclosed delimiter | ||
... | ||
LL | fn foo() { | ||
| - unclosed delimiter | ||
... | ||
LL | fn bar() { | ||
| - unclosed delimiter | ||
... | ||
LL | fn baz() { | ||
| - unclosed delimiter | ||
LL | if false { | ||
LL | { | ||
| - this delimiter might not be properly closed... | ||
LL | && let () = () | ||
LL | } | ||
| - ...as it matches this but it has different indentation | ||
LL | } | ||
| ^ | ||
|
||
error: found a `{` in the middle of a let-chain | ||
--> $DIR/brace-in-let-chain.rs:14:24 | ||
| | ||
LL | && let () = () { | ||
| ^ | ||
LL | && let () = () | ||
| ------ you might have meant to continue the let-chain here | ||
| | ||
help: consider removing this brace to parse the `let` as part of the same chain | ||
| | ||
LL - && let () = () { | ||
LL + && let () = () | ||
| | ||
|
||
error: found a `{` in the middle of a let-chain | ||
--> $DIR/brace-in-let-chain.rs:6:24 | ||
| | ||
LL | && let () = () { | ||
| ^ | ||
LL | && let () = () | ||
| ------ you might have meant to continue the let-chain here | ||
| | ||
help: consider removing this brace to parse the `let` as part of the same chain | ||
| | ||
LL - && let () = () { | ||
LL + && let () = () | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|
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.
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.
I'm trying to decide if it's better in general to silence this error (like we do for diff markers) or not is best for these cases... I would leave it as is for now, because I don't know if I can come up with a case where doing so would be detrimental, but suspect we can silence it.