-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improve spans when splitting multi-char operator tokens for proc macros. #102639
Conversation
3c05485
to
88dab8d
Compare
let hi = lo + BytePos::from_usize(1); | ||
span.with_lo(lo).with_hi(hi) | ||
} else { | ||
span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
@bors r+ |
Thank you for the fast review. @bors rollup=always |
…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
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