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

fix(parse): return unpected when current token is EOF #111181

Merged
merged 1 commit into from
May 27, 2023

Conversation

bvanjoi
Copy link
Contributor

@bvanjoi bvanjoi commented May 4, 2023

close #111148

#111148 panic occurred because FatalError.raise() was encountered which caused by Eof and Pound(the last token) had same span, when parsing # in fn a<<i<Y<w<>#.

image

There are a few ways to solve this problem:

  • Change the action assign for self.last_unexpected_token_span, for example, if current token is Eof, then return Error directly.
  • Avoid triggering the FatalError when the current token is Eof.

I have chosen the second option because executing expected_one_of_not_found when the token is Eof but not in ediable seems reasonable.

@rustbot
Copy link
Collaborator

rustbot commented May 4, 2023

r? @davidtwco

(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 May 4, 2023
@compiler-errors
Copy link
Member

Can you leave some explanation why this fixes the issue? I think I understand the corner case it's trying to avoid here, but I'm not totally sure.

@bvanjoi
Copy link
Contributor Author

bvanjoi commented May 6, 2023

Can you leave some explanation why this fixes the issue? I think I understand the corner case it's trying to avoid here, but I'm not totally sure.

I have included a few descriptions in this PR, and I would really appreciate your valuable suggestions and feedback, whether it pertains to the code or the descriptions themselves.

@compiler-errors compiler-errors self-assigned this May 8, 2023
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the suggested change

compiler/rustc_parse/src/parser/mod.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@bvanjoi bvanjoi force-pushed the fix-issue-111148 branch from 2bc4b72 to 272dc5a Compare May 12, 2023 16:33
@compiler-errors compiler-errors removed their assignment May 23, 2023
@jyn514
Copy link
Member

jyn514 commented May 27, 2023

@bors r=davidtwco rollup

@bors
Copy link
Contributor

bors commented May 27, 2023

📌 Commit 272dc5a has been approved by davidtwco

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 May 27, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 27, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#108630 (Fix docs for `alloc::realloc`)
 - rust-lang#109084 (rustc driver: Remove argument 0 before at-expansion to prevent ICE)
 - rust-lang#111181 (fix(parse): return unpected when current token is EOF)
 - rust-lang#111656 (Use an unbounded lifetime in `String::leak`.)
 - rust-lang#111946 (rustdoc: Add `ItemTemplate` trait and related functions to avoid repetitively wrapping existing functions)
 - rust-lang#112018 (Clean up usage of `cx.tcx` when `tcx` is already set into a variable)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 97fae38 into rust-lang:master May 27, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

internal compiler error: no errors encountered even though delay_span_bug issued
7 participants