Skip to content

proc_macro: Fix expand_expr expansion of bool literals - #98463

Merged
bors merged 1 commit into
rust-lang:masterfrom
mystor:expand_expr_bool
Jul 10, 2022
Merged

proc_macro: Fix expand_expr expansion of bool literals#98463
bors merged 1 commit into
rust-lang:masterfrom
mystor:expand_expr_bool

Conversation

@mystor

Copy link
Copy Markdown
Contributor

Previously, the expand_expr method would expand bool literals as a
Literal token containing a LitKind::Bool, rather than as an Ident.
This is not a valid token, and the LitKind::Bool case needs to be
handled seperately.

Tests were added to more deeply compare the streams in the expand-expr
test suite to catch mistakes like this in the future.

Previously, the expand_expr method would expand bool literals as a
`Literal` token containing a `LitKind::Bool`, rather than as an `Ident`.
This is not a valid token, and the `LitKind::Bool` case needs to be
handled seperately.
Tests were added to more deeply compare the streams in the expand-expr
test suite to catch mistakes like this in the future.
@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 24, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @wesleywiser

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 24, 2022
@mystor
mystor marked this pull request as ready for review June 25, 2022 14:35
@mystor

Copy link
Copy Markdown
ContributorAuthor

Oops, I did not mean to open this as a draft.

@wesleywiser

Copy link
Copy Markdown
Member

This looks ok to me but I know very little about proc macros.

@mystor are there any compatibility issues with this change that you are aware of? Specifically, I'm imagining something like a proc macro that expects to get a token tree of Literal(..., "true", ...) instead of Ident("true", ...) and now fails to parse it correctly. Is that a concern?

@mystor

Copy link
Copy Markdown
ContributorAuthor

I highly doubt that there are any major crates which are using this API, given that it was fairly recently introduced (last november, #87264), and hasn't even been exposed as an unstable API from proc-macro2 yet.

It appears that only 2 crates even enable the unstable feature (thanks @m-ou-se for helping me search!): https://crates.io/crates/nyar-macro, and https://crates.io/crates/include-transformed. nyar-macro doesn't appear to even call the method, and enables the feature unnecessarily, and include-transformed only uses the API to expand string literals, so won't notice any changes to how bools are handled.

@eddyb

eddyb commented Jul 9, 2022

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jul 9, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit fb5b7b4 has been approved by eddyb

It is now in the queue for this repository.

@borsbors 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 Jul 9, 2022
@bors

bors commented Jul 10, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit fb5b7b4 with merge 29554c0...

@bors

bors commented Jul 10, 2022

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: eddyb
Pushing 29554c0 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Jul 10, 2022
@bors
bors merged commit 29554c0 into rust-lang:masterJul 10, 2022
@rustbotrustbot added this to the 1.64.0 milestone Jul 10, 2022
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (29554c0): comparison url.

Instruction count

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

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regression found
mean1maxcount2
Regressions 😿
(primary)
N/AN/A0
Regressions 😿
(secondary)
2.6%2.6%1
Improvements 🎉
(primary)
N/AN/A0
Improvements 🎉
(secondary)
N/AN/A0
All 😿🎉 (primary)N/AN/A0

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 🎉 relevant improvement found
mean1maxcount2
Regressions 😿
(primary)
N/AN/A0
Regressions 😿
(secondary)
N/AN/A0
Improvements 🎉
(primary)
-3.0%-3.0%1
Improvements 🎉
(secondary)
-2.9%-2.9%1
All 😿🎉 (primary)-3.0%-3.0%1

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change2

  2. number of relevant changes2

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

7 participants

@mystor@rust-highfive@wesleywiser@eddyb@bors@rust-timer@rustbot