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

Show note where the macro failed to match #103439

Merged
merged 1 commit into from
Nov 15, 2022

Conversation

Noratrieb
Copy link
Member

@Noratrieb Noratrieb commented Oct 23, 2022

When feeding the wrong tokens, it used to fail with a very generic error that wasn't very helpful. This change tries to help by noting where specifically the matching went wrong.

macro_rules! uwu {
    (a a a b) => {};
}
uwu! { a a a c }
error: no rules expected the token `c`
 --> macros.rs:5:14
  |
1 | macro_rules! uwu {
  | ---------------- when calling this macro
...
4 | uwu! { a a a c }
  |              ^ no rules expected this token in macro call
  |
+note: while trying to match `b`
+ --> macros.rs:2:12
+  |
+2 |     (a a a b) => {};
+  |            ^

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 23, 2022
@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 Oct 23, 2022
@Dylan-DPC
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 23, 2022
@bors
Copy link
Contributor

bors commented Oct 23, 2022

⌛ Trying commit 03254db9f4cfd213bb6ba05fa435097b51aabe89 with merge 1b60c6801809977dd5201067b34e8f2ffb884eb0...

@bors
Copy link
Contributor

bors commented Oct 23, 2022

☀️ Try build successful - checks-actions
Build commit: 1b60c6801809977dd5201067b34e8f2ffb884eb0 (1b60c6801809977dd5201067b34e8f2ffb884eb0)

@rust-timer
Copy link
Collaborator

Queued 1b60c6801809977dd5201067b34e8f2ffb884eb0 with parent 9be2f35, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1b60c6801809977dd5201067b34e8f2ffb884eb0): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
2.0% [0.2%, 7.0%] 31
Regressions ❌
(secondary)
2.2% [0.6%, 4.9%] 18
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.9% [-0.6%, 7.0%] 32

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.0% [-5.0%, -5.0%] 1
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
4.4% [2.1%, 6.4%] 8
Regressions ❌
(secondary)
3.3% [2.1%, 5.1%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.4% [2.1%, 6.4%] 8

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 23, 2022
@Noratrieb
Copy link
Member Author

Yes, as expected, the naive implementation is a regression as this path is very hot. I'll reimplement the diagnostic in a different way that keeps all new code in the cold diagnostics path.

@lcnr
Copy link
Contributor

lcnr commented Oct 24, 2022

r? compiler

@rust-highfive rust-highfive assigned estebank and unassigned lcnr Oct 24, 2022
@Noratrieb
Copy link
Member Author

Noratrieb commented Oct 24, 2022

this needs some more work and won't be ready for review for a while

@rustbot author

@rustbot rustbot 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 Oct 24, 2022
@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb force-pushed the help-me-with-my-macro branch 4 times, most recently from 5e8600a to a9d7d01 Compare October 27, 2022 20:16
@compiler-errors
Copy link
Member

@bors try @rust-timer queue

@bors
Copy link
Contributor

bors commented Nov 14, 2022

📌 Commit a34d1cfde326eec323e61f8701e0fac780b322e2 has been approved by estebank

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 14, 2022
@Noratrieb
Copy link
Member Author

@estebank oh, I actually wanted to fix a few more diagnostics here before putting it up for review again but I've changed my mind on that, I think merging this is fine as is.. but can you r- it so I at least fix the commit message? :)

@compiler-errors
Copy link
Member

@bors r-
@rustbot author

yeet

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 14, 2022
@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 14, 2022
This shows a small note on what the macro matcher was currently
processing to aid with "no rules expected the token X" errors.
@Noratrieb
Copy link
Member Author

So, this should be fine now.
@rustbot ready

@rustbot rustbot 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 Nov 14, 2022
@compiler-errors
Copy link
Member

@bors r=estebank

@bors
Copy link
Contributor

bors commented Nov 14, 2022

📌 Commit 7e7c11c has been approved by estebank

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 Nov 14, 2022
@compiler-errors
Copy link
Member

@bors rollup-

RalfJung pushed a commit to RalfJung/miri that referenced this pull request Nov 15, 2022
Retry failed macro matching for diagnostics

When a declarative macro fails to match, retry the matching to collect diagnostic info instead of collecting it on the fly in the hot path. Split out of #103439.

You made a bunch of changes to declarative macro matching, so
r? `@nnethercote`

This change should produce a few small perf wins: rust-lang/rust#103439 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 15, 2022
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#103439 (Show note where the macro failed to match)
 - rust-lang#103734 (Adjust stabilization version to 1.65.0 for wasi fds)
 - rust-lang#104148 (Visit attributes of trait impl items during AST validation)
 - rust-lang#104241 (Move most of unwind's build script to lib.rs)
 - rust-lang#104258 (Deduce closure signature from a type alias `impl Trait`'s supertraits)
 - rust-lang#104296 (Walk types more carefully in `ProhibitOpaqueTypes` visitor)
 - rust-lang#104309 (Slightly improve error message for invalid identifier)
 - rust-lang#104316 (Simplify suggestions for errors in generators.)
 - rust-lang#104339 (Add `rustc_deny_explicit_impl`)

Failed merges:

 - rust-lang#103484 (Add `rust` to `let_underscore_lock` example)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1a6ed30 into rust-lang:master Nov 15, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 15, 2022
@Noratrieb Noratrieb deleted the help-me-with-my-macro branch November 15, 2022 16:20
@C0RR1T
Copy link

C0RR1T commented Nov 15, 2022

Hyped for this one

@Noratrieb Noratrieb restored the help-me-with-my-macro branch December 3, 2022 19:44
@Noratrieb Noratrieb deleted the help-me-with-my-macro branch December 23, 2022 21:04
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 20, 2024
Retry failed macro matching for diagnostics

When a declarative macro fails to match, retry the matching to collect diagnostic info instead of collecting it on the fly in the hot path. Split out of #103439.

You made a bunch of changes to declarative macro matching, so
r? `@nnethercote`

This change should produce a few small perf wins: rust-lang/rust#103439 (comment)
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
Retry failed macro matching for diagnostics

When a declarative macro fails to match, retry the matching to collect diagnostic info instead of collecting it on the fly in the hot path. Split out of #103439.

You made a bunch of changes to declarative macro matching, so
r? `@nnethercote`

This change should produce a few small perf wins: rust-lang/rust#103439 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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.