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

Revert "Teach parser to understand fake anonymous enum syntax" and related commits #107478

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

compiler-errors
Copy link
Member

anonymous enum types are currently ambiguous in positions like:

  • | operator: a as fn() -> B | C
  • closure args: |_: as fn() -> A | B

I first tried to thread around RecoverAnonEnum into all these positions, but the resulting complexity in the compiler is IMO not worth it, or at least worth a bit more thinking time. In the mean time, let's revert this syntax for now, so we can go back to the drawing board.

Fixes #107461

cc: @estebank @cjgillot #106960


Squashed revert commits:

Revert "review comment: Remove AST AnonTy"

This reverts commit 020cca8.

Revert "Ensure macros are not affected"

This reverts commit 12d18e4.

Revert "Emit fewer errors on patterns with possible type ascription"

This reverts commit c847a01.

Revert "Teach parser to understand fake anonymous enum syntax"

This reverts commit 2d82420.

@rustbot
Copy link
Collaborator

rustbot commented Jan 30, 2023

r? @oli-obk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 30, 2023
@estebank
Copy link
Contributor

@compiler-errors can you add tests for those ambiguous case, in case someone tries to do this again?

r=me

@compiler-errors
Copy link
Member Author

I did in 859b14ce7d469bc1af3ee396fd8e91b7b2e20d6f 😸

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jan 30, 2023

📌 Commit 859b14ce7d469bc1af3ee396fd8e91b7b2e20d6f has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2023
@estebank
Copy link
Contributor

I first tried to thread around RecoverAnonEnum into all these positions, but the resulting complexity in the compiler is IMO not worth it, or at least worth a bit more thinking time.

I think that instead we can rely on global Parser state to control when these kinds of anon enums can be detected. I have global state, but it is a natural communication mechanism for the parser :-/

@estebank
Copy link
Contributor

I just noticed that the type ascription in patterns change is also being reverted here. Would you mind relanding those on their own?

@compiler-errors
Copy link
Member Author

@estebank oh yes, let me re-teach the compiler those really quick. Sorry, I totally overlooked those because they weren't their own commit 😅

@compiler-errors
Copy link
Member Author

Added a few more test cases that shouldn't be broken when this PR is re-attempted.

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jan 31, 2023

📌 Commit daf382895f3fcd635c95bf2a95114f5ed6dc9e61 has been approved by estebank

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 1, 2023

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

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 1, 2023
@bors
Copy link
Contributor

bors commented Feb 1, 2023

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout anon-enum-tys-are-ambiguous (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self anon-enum-tys-are-ambiguous --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Removing tests/ui/parser/fake-anon-enums-in-macros.rs
Removing tests/ui/parser/anon-enums.stderr
Removing tests/ui/parser/anon-enums.rs
Auto-merging compiler/rustc_parse/src/parser/ty.rs
CONFLICT (content): Merge conflict in compiler/rustc_parse/src/parser/ty.rs
Automatic merge failed; fix conflicts and then commit the result.

@compiler-errors
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Feb 1, 2023

📌 Commit 250f530 has been approved by estebank

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 1, 2023

🌲 The tree is currently closed for pull requests below priority 50. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 1, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Feb 2, 2023
…ambiguous, r=estebank

Revert "Teach parser to understand fake anonymous enum syntax" and related commits

anonymous enum types are currently ambiguous in positions like:

* `|` operator: `a as fn() -> B | C`
* closure args: `|_: as fn() -> A | B`

I first tried to thread around `RecoverAnonEnum` into all these positions, but the resulting complexity in the compiler is IMO not worth it, or at least worth a bit more thinking time. In the mean time, let's revert this syntax for now, so we can go back to the drawing board.

Fixes rust-lang#107461

cc: `@estebank` `@cjgillot` rust-lang#106960

---
### Squashed revert commits:

Revert "review comment: Remove AST AnonTy"

This reverts commit 020cca8.

Revert "Ensure macros are not affected"

This reverts commit 12d18e4.

Revert "Emit fewer errors on patterns with possible type ascription"

This reverts commit c847a01.

Revert "Teach parser to understand fake anonymous enum syntax"

This reverts commit 2d82420.
@bors
Copy link
Contributor

bors commented Feb 2, 2023

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

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 2, 2023
…lated commits

Revert "review comment: Remove AST AnonTy"

This reverts commit 020cca8.

Revert "Ensure macros are not affected"

This reverts commit 12d18e4.

Revert "Emit fewer errors on patterns with possible type ascription"

This reverts commit c847a01.

Revert "Teach parser to understand fake anonymous enum syntax"

This reverts commit 2d82420.
@compiler-errors
Copy link
Member Author

This is bitrotty, but also P-critical 😓

@bors p=1

@compiler-errors
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Feb 2, 2023

📌 Commit 39db65c has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 2, 2023
@bors
Copy link
Contributor

bors commented Feb 2, 2023

⌛ Testing commit 39db65c with merge 97872b7...

@bors
Copy link
Contributor

bors commented Feb 2, 2023

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 97872b7 to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Feb 2, 2023

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 97872b7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 2, 2023
@bors bors merged commit 97872b7 into rust-lang:master Feb 2, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 2, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (97872b7): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.9% [1.6%, 2.3%] 2
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.4% [-1.4%, -1.4%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 3, 2023
…ler-errors

Parse and recover from type ascription in patterns

Reintroduce part of rust-lang#106960, which was reverted in rust-lang#107478.

r? `@compiler-errors`
@compiler-errors compiler-errors deleted the anon-enum-tys-are-ambiguous branch August 11, 2023 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Closure with a typed function argument and top level struct constructor break in nightly
6 participants