Skip to content
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

Syntax: Recover on `for ( $pat in $expr ) $block` #62928

Merged
merged 3 commits into from Jul 30, 2019

Conversation

@Centril
Copy link
Member

commented Jul 24, 2019

Fixes #62724 by adding some recovery:

error: unexpected closing `)`
  --> $DIR/recover-for-loop-parens-around-head.rs:10:23
   |
LL |     for ( elem in vec ) {
   |         --------------^
   |         |
   |         opening `(`
   |         help: remove parenthesis in `for` loop: `elem in vec`

The last 2 commits are drive-by cleanups.

r? @estebank

@rust-highfive

This comment was marked as spam.

Copy link
Collaborator

commented Jul 24, 2019

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@bors

This comment was marked as resolved.

Copy link
Contributor

commented Jul 27, 2019

☔️ The latest upstream changes (presumably #63029) made this pull request unmergeable. Please resolve the merge conflicts.

@Centril Centril force-pushed the Centril:recover-parens-around-for-head branch from 731cd32 to ee903d4 Jul 28, 2019

@Centril Centril force-pushed the Centril:recover-parens-around-for-head branch from ee903d4 to 56b39fb Jul 28, 2019

@Centril

This comment has been minimized.

Copy link
Member Author

commented Jul 28, 2019

#62550 merged.

@estebank this should be ready for review now.

@estebank

This comment has been minimized.

Copy link
Contributor

commented Jul 29, 2019

I'll take a look at it later today.

| --------------^
| |
| opening `(`
| help: remove parenthesis in `for` loop: `elem in vec`

This comment has been minimized.

Copy link
@estebank

estebank Jul 29, 2019

Contributor

I'm not entirely happy with the wording:

  • The span pointing at the opening brace is slightly redundant.
  • The issue is already known to be the superfluous parenthesis, so it thee maim message could be incorrect parenthesis surrounding for head or similar (probably something more user friendly).
  • The primary span points at the closing parenthesis but it doesn't have a label.
  • Suggestions that have very subtle changes sometimes make people not pay attention to the text, in this case people might not realize the lack of parenthesis in the suggested code.
  • We have two errors pointing at the problem here (the prior "in not expected" error, but it's ok emitting both for now)

IMO something like the following would be better:

error: unnecessary parenthesis surroundinig `for` loop head
  --> $DIR/recover-for-loop-parens-around-head.rs:10:23
   |
LL |     for ( elem in vec ) {
   |         ^             ^ help: remove these surrounding parenthesis

This comment has been minimized.

Copy link
@Centril

Centril Jul 29, 2019

Author Member

Filed #63113 for following up.

@estebank

This comment has been minimized.

Copy link
Contributor

commented Jul 29, 2019

@bors r+

@Centril I have some nitpicks. If you can address them shortly, go ahead, otherwise I'm ok with the PR being merged and my nitpicks addressed later.

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 29, 2019

📌 Commit 56b39fb has been approved by estebank

Centril added a commit to Centril/rust that referenced this pull request Jul 29, 2019

Rollup merge of rust-lang#62928 - Centril:recover-parens-around-for-h…
…ead, r=estebank

Syntax: Recover on `for ( $pat in $expr ) $block`

Fixes rust-lang#62724 by adding some recovery:

```
error: unexpected closing `)`
  --> $DIR/recover-for-loop-parens-around-head.rs:10:23
   |
LL |     for ( elem in vec ) {
   |         --------------^
   |         |
   |         opening `(`
   |         help: remove parenthesis in `for` loop: `elem in vec`
```

The last 2 commits are drive-by cleanups.

r? @estebank

bors added a commit that referenced this pull request Jul 29, 2019

Auto merge of #63112 - Centril:rollup-kjgv7ak, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #61965 (Remove mentions of removed `offset_to` method from `align_offset` docs)
 - #62507 (Remove derives `Encodable`/`Decodable` and unstabilize attribute `#[bench]`)
 - #62928 (Syntax: Recover on `for ( $pat in $expr ) $block`)
 - #63000 (Impl Debug for Chars)
 - #63087 (Add very simple edition check to tidy.)
 - #63093 (Properly check the defining scope of existential types)
 - #63099 (vxworks: Remove Linux-specific comments.)
 - #63108 (Add links to None in Option doc)
 - #63109 (std: Fix a failing `fs` test on Windows)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Jul 29, 2019

Rollup merge of rust-lang#62928 - Centril:recover-parens-around-for-h…
…ead, r=estebank

Syntax: Recover on `for ( $pat in $expr ) $block`

Fixes rust-lang#62724 by adding some recovery:

```
error: unexpected closing `)`
  --> $DIR/recover-for-loop-parens-around-head.rs:10:23
   |
LL |     for ( elem in vec ) {
   |         --------------^
   |         |
   |         opening `(`
   |         help: remove parenthesis in `for` loop: `elem in vec`
```

The last 2 commits are drive-by cleanups.

r? @estebank

bors added a commit that referenced this pull request Jul 29, 2019

Auto merge of #63119 - Centril:rollup-fykplr4, r=Centril
Rollup of 13 pull requests

Successful merges:

 - #61965 (Remove mentions of removed `offset_to` method from `align_offset` docs)
 - #62928 (Syntax: Recover on `for ( $pat in $expr ) $block`)
 - #63000 (Impl Debug for Chars)
 - #63059 (Make `#![feature(bind_by_move_pattern_guards)]` sound without `#[feature(nll)]`)
 - #63083 (Make generic parameters always use modern hygiene)
 - #63087 (Add very simple edition check to tidy.)
 - #63093 (Properly check the defining scope of existential types)
 - #63095 (Turn `INCOMPLETE_FEATURES` into lint)
 - #63096 (Add tests for some `existential_type` ICEs)
 - #63099 (vxworks: Remove Linux-specific comments.)
 - #63106 (ci: Skip installing SWIG/xz on OSX )
 - #63108 (Add links to None in Option doc)
 - #63109 (std: Fix a failing `fs` test on Windows)

Failed merges:

r? @ghost

bors added a commit that referenced this pull request Jul 29, 2019

Auto merge of #63119 - Centril:rollup-fykplr4, r=Centril
Rollup of 13 pull requests

Successful merges:

 - #61965 (Remove mentions of removed `offset_to` method from `align_offset` docs)
 - #62928 (Syntax: Recover on `for ( $pat in $expr ) $block`)
 - #63000 (Impl Debug for Chars)
 - #63059 (Make `#![feature(bind_by_move_pattern_guards)]` sound without `#[feature(nll)]`)
 - #63083 (Make generic parameters always use modern hygiene)
 - #63087 (Add very simple edition check to tidy.)
 - #63093 (Properly check the defining scope of existential types)
 - #63095 (Turn `INCOMPLETE_FEATURES` into lint)
 - #63096 (Add tests for some `existential_type` ICEs)
 - #63099 (vxworks: Remove Linux-specific comments.)
 - #63106 (ci: Skip installing SWIG/xz on OSX )
 - #63108 (Add links to None in Option doc)
 - #63109 (std: Fix a failing `fs` test on Windows)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Jul 30, 2019

Rollup merge of rust-lang#62928 - Centril:recover-parens-around-for-h…
…ead, r=estebank

Syntax: Recover on `for ( $pat in $expr ) $block`

Fixes rust-lang#62724 by adding some recovery:

```
error: unexpected closing `)`
  --> $DIR/recover-for-loop-parens-around-head.rs:10:23
   |
LL |     for ( elem in vec ) {
   |         --------------^
   |         |
   |         opening `(`
   |         help: remove parenthesis in `for` loop: `elem in vec`
```

The last 2 commits are drive-by cleanups.

r? @estebank

bors added a commit that referenced this pull request Jul 30, 2019

Auto merge of #63120 - Centril:rollup-swgmy2h, r=Centril
Rollup of 12 pull requests

Successful merges:

 - #61965 (Remove mentions of removed `offset_to` method from `align_offset` docs)
 - #62928 (Syntax: Recover on `for ( $pat in $expr ) $block`)
 - #63000 (Impl Debug for Chars)
 - #63059 (Make `#![feature(bind_by_move_pattern_guards)]` sound without `#[feature(nll)]`)
 - #63083 (Make generic parameters always use modern hygiene)
 - #63087 (Add very simple edition check to tidy.)
 - #63093 (Properly check the defining scope of existential types)
 - #63096 (Add tests for some `existential_type` ICEs)
 - #63099 (vxworks: Remove Linux-specific comments.)
 - #63106 (ci: Skip installing SWIG/xz on OSX )
 - #63108 (Add links to None in Option doc)
 - #63109 (std: Fix a failing `fs` test on Windows)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Jul 30, 2019

Rollup merge of rust-lang#62928 - Centril:recover-parens-around-for-h…
…ead, r=estebank

Syntax: Recover on `for ( $pat in $expr ) $block`

Fixes rust-lang#62724 by adding some recovery:

```
error: unexpected closing `)`
  --> $DIR/recover-for-loop-parens-around-head.rs:10:23
   |
LL |     for ( elem in vec ) {
   |         --------------^
   |         |
   |         opening `(`
   |         help: remove parenthesis in `for` loop: `elem in vec`
```

The last 2 commits are drive-by cleanups.

r? @estebank

bors added a commit that referenced this pull request Jul 30, 2019

Auto merge of #63124 - Centril:rollup-onohtqt, r=Centril
Rollup of 12 pull requests

Successful merges:

 - #61965 (Remove mentions of removed `offset_to` method from `align_offset` docs)
 - #62928 (Syntax: Recover on `for ( $pat in $expr ) $block`)
 - #63000 (Impl Debug for Chars)
 - #63083 (Make generic parameters always use modern hygiene)
 - #63087 (Add very simple edition check to tidy.)
 - #63093 (Properly check the defining scope of existential types)
 - #63096 (Add tests for some `existential_type` ICEs)
 - #63099 (vxworks: Remove Linux-specific comments.)
 - #63106 (ci: Skip installing SWIG/xz on OSX )
 - #63108 (Add links to None in Option doc)
 - #63109 (std: Fix a failing `fs` test on Windows)
 - #63111 (Add syntactic and semantic tests for rest patterns, i.e. `..`)

Failed merges:

r? @ghost

@bors bors merged commit 56b39fb into rust-lang:master Jul 30, 2019

4 checks passed

pr Build #20190728.47 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details

@Centril Centril deleted the Centril:recover-parens-around-for-head branch Jul 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.