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

proc_macro: Fix expand_expr expansion of bool literals #98463

Merged
merged 1 commit into from Jul 10, 2022

Conversation

mystor
Copy link
Contributor

@mystor mystor commented Jun 24, 2022

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.
@rustbot rustbot 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
Collaborator

r? @wesleywiser

(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 Jun 24, 2022
@mystor mystor marked this pull request as ready for review June 25, 2022 14:35
@mystor
Copy link
Contributor Author

mystor commented Jun 25, 2022

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

@wesleywiser
Copy link
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
Contributor Author

mystor commented Jul 7, 2022

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
Copy link
Member

eddyb commented Jul 9, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 9, 2022

📌 Commit fb5b7b4 has been approved by eddyb

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 Jul 9, 2022
@bors
Copy link
Contributor

bors commented Jul 10, 2022

⌛ Testing commit fb5b7b4 with merge 29554c0...

@bors
Copy link
Contributor

bors commented Jul 10, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 10, 2022
@bors bors merged commit 29554c0 into rust-lang:master Jul 10, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 10, 2022
@rust-timer
Copy link
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
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
2.6% 2.6% 1
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
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 change 2

  2. number of relevant changes 2

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.

None yet

7 participants