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

When snapshoting a TokenCursor, preserve the top frame of the stack #81352

Closed
wants to merge 1 commit into from

Conversation

Aaron1011
Copy link
Member

If we start capturing on the first token of a frame,
we can legally pop the frame (e.g. we can capture something like
'{ my_tokens } other_tokens'. As a result, we need to snapshot the frame
at the top of the current stack, rather than just using an empty stack.

Fixes taiki-e/pin-project#312

If we start capturing on the first token of a frame,
we can legally pop the frame (e.g. we can capture something like
'{ my_tokens } other_tokens'. As a result, we need to snapshot the frame
at the top of the current stack, rather than just using an empty stack.

Fixes taiki-e/pin-project#312
@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 24, 2021
@Aaron1011
Copy link
Member Author

r? @petrochenkov

// (e.g. the '{' in '{ my_tokens }'), then we can legally
// exit the frame (e.g. collecting '{ my_tokens } something_else'
// Therefore, we preserve the top of the stack, but nothing else
stack: self.token_cursor.stack.first().cloned().into_iter().collect(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
stack: self.token_cursor.stack.first().cloned().into_iter().collect(),
stack: if self.token_cursor.stack.is_empty() { vec![] } else { vec![TokenCursorFrame::dummy()] }

I'm not actually sure, does it matter what exactly we put into the stack here, or putting any dummy frame making stack.pop() work without panic would be enough?

I'm asking because first() is not the top of the stack, it's the bottom, but things still seem to work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, that's a good point. I'll need to take a closer look at how this is working.

@petrochenkov petrochenkov 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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 24, 2021
@Aaron1011
Copy link
Member Author

Closing in favor of #81472

@Aaron1011 Aaron1011 closed this Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[pin_project] panics with internal error: entered unreachable code when used inside a MBE with vis
4 participants