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

Implement proposed API for proc_macro_span #111571

Merged
merged 8 commits into from
Jun 28, 2023
Merged

Conversation

jhpratt
Copy link
Member

@jhpratt jhpratt commented May 14, 2023

As proposed in #54725 (comment). I have omitted the byte-level API as it's already available as Span::byte_range.

@rustbot label +A-proc-macros

r? @m-ou-se

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 14, 2023
@rustbot

This comment was marked as resolved.

@rustbot rustbot added the A-proc-macros Area: Procedural macros label May 14, 2023
Copy link
Member Author

Choose a reason for hiding this comment

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

This is something that needs addressing. I presume it has something to do with the ordering of spans, but beyond that I'm not sure what.

Copy link
Member

Choose a reason for hiding this comment

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

@estebank Do you perhaps know what happened here? Both the old and the new diagnostic output seems a bit off here. Not sure what span it is trying to point at. (And also not sure why it changed in this PR.)

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the underlying Span coming out of the macro is absolutely malformed, very likely the end comes before the start, but this is the first time I see this behavior in the test suite (things might have changed in the handling in the last six months). I'd need to dig deeper.

Copy link
Member

Choose a reason for hiding this comment

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

I beleive @dtolnay thought might be the result of error deduplication, when I asked him about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the erroneous output is at most tangentially related to this PR, should it be merged and a separate issue created for the bug?

Copy link
Member

Choose a reason for hiding this comment

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

should it be merged and a separate issue created for the bug?

I think that's the best way forward. Can you open that issue?

@rust-log-analyzer

This comment was marked as resolved.

@rustbot

This comment was marked as resolved.

Copy link
Member

@m-ou-se m-ou-se left a comment

Choose a reason for hiding this comment

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

This looks fine to me, but I don't know what's up with tests/ui/macros/same-sequence-span.stderr.

@bors
Copy link
Contributor

bors commented May 18, 2023

☔ The latest upstream changes (presumably #111710) made this pull request unmergeable. Please resolve the merge conflicts.

library/proc_macro/src/lib.rs Outdated Show resolved Hide resolved
library/proc_macro/src/lib.rs Outdated Show resolved Hide resolved
@m-ou-se
Copy link
Member

m-ou-se commented Jun 5, 2023

Implementation looks fine to me. r=me with that issue filed and conflict resolved.

@m-ou-se m-ou-se 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 Jun 5, 2023
@jhpratt jhpratt force-pushed the proc-macro-span branch from 4f7a9e2 to 1bea9ee Compare June 6, 2023 19:02
@rust-log-analyzer

This comment has been minimized.

@jhpratt jhpratt force-pushed the proc-macro-span branch from 1bea9ee to 6758d41 Compare June 6, 2023 19:09
@rust-log-analyzer

This comment has been minimized.

@jhpratt jhpratt force-pushed the proc-macro-span branch from 6758d41 to ec3423b Compare June 6, 2023 19:15
@rust-log-analyzer

This comment has been minimized.

@jhpratt jhpratt force-pushed the proc-macro-span branch from ec3423b to 6debc94 Compare June 6, 2023 19:23
@rust-log-analyzer

This comment has been minimized.

@jhpratt
Copy link
Member Author

jhpratt commented Jun 6, 2023

cc @dtolnay — looks like merging proc_macro_span and proc_macro_span_shrink cause proc_macro2 to fail to compile again.

@bors
Copy link
Contributor

bors commented Jun 27, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 27, 2023
TaKO8Ki added a commit to TaKO8Ki/rust that referenced this pull request Jun 27, 2023
Implement proposed API for `proc_macro_span`

As proposed in [rust-lang#54725 (comment)](rust-lang#54725 (comment)). I have omitted the byte-level API as it's already available as [`Span::byte_range`](https://doc.rust-lang.org/nightly/proc_macro/struct.Span.html#method.byte_range).

`@rustbot` label +A-proc-macros

r? `@m-ou-se`
@jhpratt
Copy link
Member Author

jhpratt commented Jun 28, 2023

Not sure what to make of that error.

@m-ou-se
Copy link
Member

m-ou-se commented Jun 28, 2023

@bors retry

@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 Jun 28, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 28, 2023
Rollup of 6 pull requests

Successful merges:

 - rust-lang#111571 (Implement proposed API for `proc_macro_span`)
 - rust-lang#112236 (Simplify computation of killed borrows)
 - rust-lang#112867 (More `ImplSource` nits)
 - rust-lang#113019 (add note for non-exhaustive matches with guards)
 - rust-lang#113094 (Fix invalid HTML DIV tag used in HEAD)
 - rust-lang#113111 (add myself to review for t-types stuff)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fa56e01 into rust-lang:master Jun 28, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 28, 2023
martin-t added a commit to martin-t/cvars that referenced this pull request Jun 30, 2023
Should fix CI fail after rust-lang/rust#111571
MingweiSamuel added a commit to hydro-project/proc-macro2 that referenced this pull request Jun 30, 2023
MingweiSamuel added a commit to hydro-project/proc-macro2 that referenced this pull request Jun 30, 2023
@jhpratt jhpratt deleted the proc-macro-span branch July 1, 2023 21:31
udoprog pushed a commit to udoprog/proc-macro2 that referenced this pull request Aug 21, 2023
kodiakhq bot referenced this pull request in X-oss-byte/Nextjs Sep 22, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [proc-macro2](https://togithub.com/dtolnay/proc-macro2) | workspace.dependencies | patch | `1.0.51` -> `1.0.67` |

---

### Release Notes

<details>
<summary>dtolnay/proc-macro2 (proc-macro2)</summary>

### [`v1.0.67`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.67)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.66...1.0.67)

-   Special handling for the `(/*ERROR*/)` placeholder that rustc uses for macros that fail to expand ([#&#8203;405](https://togithub.com/dtolnay/proc-macro2/issues/405))

### [`v1.0.66`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.66)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.65...1.0.66)

-   Raise required compiler from Rust 1.31 to 1.56

### [`v1.0.65`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.65)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.64...1.0.65)

-   Documentation improvements

### [`v1.0.64`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.64)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.63...1.0.64)

-   Fix parsing of bare `\r` in between tokens ([#&#8203;399](https://togithub.com/dtolnay/proc-macro2/issues/399))

### [`v1.0.63`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.63)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.62...1.0.63)

-   Parse `c"…"` c-string literals (tracking issue: [https://github.com/rust-lang/rust/issues/105723](https://togithub.com/rust-lang/rust/issues/105723))

### [`v1.0.62`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.62)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.61...1.0.62)

*yanked*

### [`v1.0.61`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.61)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.60...1.0.61)

-   Stricter parsing of whitespace in cooked string literals and between tokens ([#&#8203;392](https://togithub.com/dtolnay/proc-macro2/issues/392), [#&#8203;393](https://togithub.com/dtolnay/proc-macro2/issues/393))

### [`v1.0.60`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.60)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.59...1.0.60)

-   Eliminate uses of unstable proc_macro::Span::before/after ([#&#8203;391](https://togithub.com/dtolnay/proc-macro2/issues/391))

### [`v1.0.59`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.59)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.58...1.0.59)

-   Enable proc_macro support on wasm targets ([#&#8203;388](https://togithub.com/dtolnay/proc-macro2/issues/388))

### [`v1.0.58`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.58)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.57...1.0.58)

-   Make rustc version detection more robust by compiling against modernest stable features ([#&#8203;384](https://togithub.com/dtolnay/proc-macro2/issues/384))

### [`v1.0.57`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.57)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.56...1.0.57)

-   Disable nightly-only `start()`/`end()` implementation on `Span` while the upstream API is iterated on ([#&#8203;383](https://togithub.com/dtolnay/proc-macro2/issues/383), [https://github.com/rust-lang/rust/pull/111571](https://togithub.com/rust-lang/rust/pull/111571))

### [`v1.0.56`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.56)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.55...1.0.56)

-   Circumvent clippy::octal_escapes lint inside generated string and byte-string literals ([#&#8203;363](https://togithub.com/dtolnay/proc-macro2/issues/363), [#&#8203;380](https://togithub.com/dtolnay/proc-macro2/issues/380))
-   Provide RefUnwindSafe impls for compilers older than 1.58 ([#&#8203;382](https://togithub.com/dtolnay/proc-macro2/issues/382))

### [`v1.0.55`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.55)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.54...1.0.55)

-   Set a meaningful `Span` for literals produced via the `FromStr` impl of `Literal` ([#&#8203;378](https://togithub.com/dtolnay/proc-macro2/issues/378))
-   Implement `Literal::subspan` in non-macro contexts when "span-locations" feature is enabled ([#&#8203;379](https://togithub.com/dtolnay/proc-macro2/issues/379))

### [`v1.0.54`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.54)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.53...1.0.54)

-   Performance improvement to "span-locations" feature ([#&#8203;373](https://togithub.com/dtolnay/proc-macro2/issues/373))
-   Fix unbounded memory usage when calling proc-macro2's parser from a fuzzer ([#&#8203;374](https://togithub.com/dtolnay/proc-macro2/issues/374))

### [`v1.0.53`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.53)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.52...1.0.53)

-   Add support for Rust 1.66's `source_text()` method ([#&#8203;350](https://togithub.com/dtolnay/proc-macro2/issues/350))

### [`v1.0.52`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.52)

[Compare Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.51...1.0.52)

-   Add [`Group::delim_span`](https://docs.rs/proc-macro2/1.0.52/proc_macro2/struct.Group.html#method.delim_span) ([#&#8203;366](https://togithub.com/dtolnay/proc-macro2/issues/366))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/sammyfilly/Nextjs).
MingweiSamuel added a commit to hydro-project/proc-macro2 that referenced this pull request Mar 26, 2024
MingweiSamuel added a commit to hydro-project/proc-macro2 that referenced this pull request Mar 26, 2024
MingweiSamuel added a commit to hydro-project/proc-macro2 that referenced this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macros Area: Procedural macros S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

8 participants