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

Synthesize a TokenStream for StmtKind::Empty #80789

Merged
merged 1 commit into from
Jan 10, 2021

Conversation

Aaron1011
Copy link
Member

Fixes #80760

@rust-highfive
Copy link
Collaborator

r? @lcnr

(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 7, 2021
@lcnr
Copy link
Contributor

lcnr commented Jan 7, 2021

r? @petrochenkov probably

@rust-highfive rust-highfive assigned petrochenkov and unassigned lcnr Jan 7, 2021
@bors

This comment has been minimized.

@petrochenkov
Copy link
Contributor

petrochenkov commented Jan 7, 2021

StmtKind::Empty is only for diagnostics they said, we only want to report a lint they said.
1.5 years pass and ; is already a full-fledged statement accepted by stmt matcher, just through the power of natural bug evolution.

At least

#[attr]
;

is not supported yet.

@petrochenkov
Copy link
Contributor

At least #[attr] ; is not supported yet.

Oh well.

macro_rules! m {
    ($stmt:stmt) => { #[allow(bad_style)] $stmt }
}

fn main() {
    m!(;);
}

@petrochenkov
Copy link
Contributor

I can't complain about the end result, but the process here was funny.
Of course, to align with the token-based expansion model better ; would eventually become a statement, with some lang team process and approval, but until then it was still supposed to be only a "filler" between other statements, a part of the block syntax.

@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 9, 2021
@Aaron1011
Copy link
Member Author

@petrochenkov: The current behavior w.r.t to attributes is very odd - any attributes added via #[attr] $empty_stmt are not actually invoked. I've added a test to ensure that we detect if this changes.

@Aaron1011 Aaron1011 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 9, 2021
@petrochenkov
Copy link
Contributor

r=me after moving the common part prepend_attrs(sess, stmt.attrs(), nt, ...) to outside of the condition.

@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 9, 2021
@Aaron1011
Copy link
Member Author

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented Jan 9, 2021

📌 Commit 3ed6caa has been approved by petrochenkov

@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 Jan 9, 2021
@bors
Copy link
Contributor

bors commented Jan 10, 2021

⌛ Testing commit 3ed6caa with merge 080ee6f...

@bors
Copy link
Contributor

bors commented Jan 10, 2021

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 080ee6f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 10, 2021
@bors bors merged commit 080ee6f into rust-lang:master Jan 10, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 10, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic with 'Missing tokens for nt ";"' when passing statement to proc macro from declarative macro
6 participants