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

Improve spans on evaluated cfg_attrs. #128133

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jul 24, 2024

When converting something like #![cfg_attr(cond, attr)] into #![attr], we currently duplicate the # token and the ! token. But weirdly, there is also this comment:

// We don't really have a good span to use for the synthesized []
// in #[attr], so just use the span of the # token.

Maybe that comment used to be true? But now it is false: we can duplicate the existing delimiters (and their spans and spacing), much like we do for the # and !.

This commit does that, thus removing the incorrect comment, and improving the spans on Groups in a few proc-macro tests.

@petrochenkov

When converting something like `#![cfg_attr(cond, attr)]` into
`#![attr]`, we currently duplicate the `#` token and the `!` token. But
weirdly, there is also this comment:

// We don't really have a good span to use for the synthesized `[]`
// in `#[attr]`, so just use the span of the `#` token.

Maybe that comment used to be true? But now it is false: we can
duplicate the existing delimiters (and their spans and spacing), much
like we do for the `#` and `!`.

This commit does that, thus removing the incorrect comment, and
improving the spans on `Group`s in a few proc-macro tests.
@rustbot
Copy link
Collaborator

rustbot commented Jul 24, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Jul 24, 2024
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 24, 2024

📌 Commit ac26b88 has been approved by petrochenkov

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 24, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 24, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#126152 (size_of_val_raw: for length 0 this is safe to call)
 - rust-lang#127252 (Add edge-case examples to `{count,leading,trailing}_{ones,zeros}` methods)
 - rust-lang#127374 (Tweak "wrong # of generics" suggestions)
 - rust-lang#127457 (Make tidy fast without compromising case alternation)
 - rust-lang#127480 (Fix build failure on vxworks rust-lang#127084 )
 - rust-lang#127733 (Replace some `mem::forget`'s with `ManuallyDrop`)
 - rust-lang#128120 (Gate `AsyncFn*` under `async_closure` feature)
 - rust-lang#128131 (Import `c_void` rather than using the full path)
 - rust-lang#128133 (Improve spans on evaluated `cfg_attr`s.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2dc88bf into rust-lang:master Jul 24, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 24, 2024
Rollup merge of rust-lang#128133 - nnethercote:fix-cfg_attr-spans, r=petrochenkov

Improve spans on evaluated `cfg_attr`s.

When converting something like `#![cfg_attr(cond, attr)]` into `#![attr]`, we currently duplicate the `#` token and the `!` token. But weirdly, there is also this comment:

// We don't really have a good span to use for the synthesized `[]`
// in `#[attr]`, so just use the span of the `#` token.

Maybe that comment used to be true? But now it is false: we can duplicate the existing delimiters (and their spans and spacing), much like we do for the `#` and `!`.

This commit does that, thus removing the incorrect comment, and improving the spans on `Group`s in a few proc-macro tests.

`@petrochenkov`
@rustbot rustbot added this to the 1.82.0 milestone Jul 24, 2024
@nnethercote nnethercote deleted the fix-cfg_attr-spans branch July 26, 2024 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants