Improve spans when splitting multi-char operator tokens for proc macros.#102639
Merged
bors merged 2 commits intorust-lang:masterfrom Oct 4, 2022
Merged
Improve spans when splitting multi-char operator tokens for proc macros.#102639bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
3c05485 to
88dab8d
Compare
Aaron1011
reviewed
Oct 3, 2022
| let hi = lo + BytePos::from_usize(1); | ||
| span.with_lo(lo).with_hi(hi) | ||
| } else { | ||
| span |
Contributor
There was a problem hiding this comment.
Could you add a test that exercises this (if there isn't one already)? You should be able to use quote! to get tokens with a weird enough span.
Contributor
Author
There was a problem hiding this comment.
There are already tests that cover this. (That's how I found out about such spans.) If I remove the length check, the following ui tests fail:
failures:
[ui] src/test/ui/proc-macro/doc-comment-preserved.rs
[ui] src/test/ui/proc-macro/inner-attr-non-inline-mod.rs
[ui] src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs
[ui] src/test/ui/proc-macro/issue-81007-item-attrs.rs
[ui] src/test/ui/proc-macro/meta-macro-hygiene.rs
For example, in src/test/ui/proc-macro/inner-attr-non-inline-mod.rs every token passed to the proc macro has a span of $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23.
Contributor
|
@bors r+ |
Collaborator
Contributor
Author
|
Thank you for the fast review. @bors rollup=always |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 4, 2022
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#102441 (Suggest unwrap_or_else when a closure is given) - rust-lang#102547 (Migrate CSS theme for search results) - rust-lang#102567 (Delay evaluating lint primary message until after it would be suppressed) - rust-lang#102624 (rustdoc: remove font family CSS on `.rustdoc-toggle summary::before`) - rust-lang#102628 (Change the parameter name of From::from to `value`) - rust-lang#102637 (Ignore fuchsia on two compiler tests) - rust-lang#102639 (Improve spans when splitting multi-char operator tokens for proc macros.) Failed merges: - rust-lang#102496 (Suggest `.into()` when all other coercion suggestions fail) r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a two-char (or three-char) operator token is split into single-char operator tokens before being passed to a proc macro, the single-char tokens are given the original span of length two (or three). This PR gives them more accurate spans.
r? @Aaron1011
cc @petrochenkov